

set more off
mat drop _all


use "$path_data/data/temp/main_reg_data.dta", clear








foreach i in DT_per_min DT_score DT_time  {

	 regress dif_`i' treatment if `i'_pre != ., cluster(school_no)

	matrix ORI1_dif_`i'_temp = r(table)
	matrix ORI1_dif_`i'_r2 = e(r2)
	matrix ORI1_dif_`i'_obs = e(N)

	 cgmwildboot_2 dif_`i' treatment if `i'_pre != ., cluster(school_no) bootcluster(school_no) null(0) reps(999) seed(1)
	matrix ORI1_dif_`i'_temp_p = e(Pvals)

	
	foreach s in be se pv rpv wpv {
		matrix ORI1_dif_`i'_`s' = J(7,1,.)
	}

	foreach j in 1 2 3 4 5 6 7 {
		* beta
		matrix ORI1_dif_`i'_be[`j',1] = ORI1_dif_`i'_temp[1,`j']
		* standard error
		matrix ORI1_dif_`i'_se[`j',1] = ORI1_dif_`i'_temp[2,`j']
		* p value
		matrix ORI1_dif_`i'_pv[`j',1] = ORI1_dif_`i'_temp[4,`j']
		matrix ORI1_dif_`i'_wpv[`j',1] = ORI1_dif_`i'_temp_p[`j',1]
	}

*	cgmwildboot `i' treatment wrongDT cheating wrongTshort wrongTlong dum_grade, ///
*	cluster(school_no) bootcluster(school_no) null(0 . . . . . ) reps(999) seed(1)


	
}

foreach i in dif_PTS_cog {

	 regress `i' treatment if ptsbl_overall_score != ., cluster(school_no)

	matrix ORI1_`i'_temp = r(table)
	matrix ORI1_`i'_r2 = e(r2)
	matrix ORI1_`i'_obs = e(N)

	 cgmwildboot_2 `i' treatment if ptsbl_overall_score != ., cluster(school_no) bootcluster(school_no) null(0) reps(999) seed(1)
	matrix ORI1_`i'_temp_p = e(Pvals)

	
	foreach s in be se pv rpv wpv {
		matrix ORI1_`i'_`s' = J(7,1,.)
	}

	foreach j in 1 2 3 4 5 6 7 {
		* beta
		matrix ORI1_`i'_be[`j',1] = ORI1_`i'_temp[1,`j']
		* standard error
		matrix ORI1_`i'_se[`j',1] = ORI1_`i'_temp[2,`j']
		* p value
		matrix ORI1_`i'_pv[`j',1] = ORI1_`i'_temp[4,`j']
		matrix ORI1_`i'_wpv[`j',1] = ORI1_`i'_temp_p[`j',1]
	}

*	cgmwildboot `i' treatment wrongDT cheating wrongTshort wrongTlong dum_grade, ///
*	cluster(school_no) bootcluster(school_no) null(0 . . . . . ) reps(999) seed(1)


	
}




foreach i in rosen cpcs {

	 regress dif_`i' treatment if `i'_bl != ., cluster(school_no)

	matrix ORI1_dif_`i'_temp = r(table)
	matrix ORI1_dif_`i'_r2 = e(r2)
	matrix ORI1_dif_`i'_obs = e(N)

	 cgmwildboot_2 dif_`i' treatment if `i'_bl != ., cluster(school_no) bootcluster(school_no) null(0) reps(999) seed(1)
	matrix ORI1_dif_`i'_temp_p = e(Pvals)

	
	foreach s in be se pv rpv wpv {
		matrix ORI1_dif_`i'_`s' = J(7,1,.)
	}

	foreach j in 1 2 3 4 5 6 7 {
		* beta
		matrix ORI1_dif_`i'_be[`j',1] = ORI1_dif_`i'_temp[1,`j']
		* standard error
		matrix ORI1_dif_`i'_se[`j',1] = ORI1_dif_`i'_temp[2,`j']
		* p value
		matrix ORI1_dif_`i'_pv[`j',1] = ORI1_dif_`i'_temp[4,`j']
		matrix ORI1_dif_`i'_wpv[`j',1] = ORI1_dif_`i'_temp_p[`j',1]
	}

*	cgmwildboot `i' treatment wrongDT cheating wrongTshort wrongTlong dum_grade, ///
*	cluster(school_no) bootcluster(school_no) null(0 . . . . . ) reps(999) seed(1)


	
}

foreach s in be se pv r2 rpv obs wpv {
	matrix ORI1_`s' = ORI1_dif_DT_per_min_`s', ORI1_dif_DT_score_`s', ///
	ORI1_dif_DT_time_`s', ORI1_dif_PTS_cog_`s', ///
	ORI1_dif_rosen_`s', ORI1_dif_cpcs_`s'
}











foreach i in DT_per_min DT_score DT_time  {

	 regress `i'_post treatment if `i'_pre != ., cluster(school_no)

	matrix ORI2_`i'_post_temp = r(table)
	matrix ORI2_`i'_post_r2 = e(r2)
	matrix ORI2_`i'_post_obs = e(N)

	 cgmwildboot_2 `i'_post treatment if `i'_pre != ., cluster(school_no) bootcluster(school_no) null(0) reps(999) seed(1)
	matrix ORI2_`i'_post_temp_p = e(Pvals)

	
	foreach s in be se pv rpv wpv {
		matrix ORI2_`i'_post_`s' = J(7,1,.)
	}

	foreach j in 1 2 3 4 5 6 7 {
		* beta
		matrix ORI2_`i'_post_be[`j',1] = ORI2_`i'_post_temp[1,`j']
		* standard error
		matrix ORI2_`i'_post_se[`j',1] = ORI2_`i'_post_temp[2,`j']
		* p value
		matrix ORI2_`i'_post_pv[`j',1] = ORI2_`i'_post_temp[4,`j']
		matrix ORI2_`i'_post_wpv[`j',1] = ORI2_`i'_post_temp_p[`j',1]
	}

*	cgmwildboot `i' treatment wrongDT cheating wrongTshort wrongTlong dum_grade, ///
*	cluster(school_no) bootcluster(school_no) null(0 . . . . . ) reps(999) seed(1)


	
}

foreach i in ptsel_overall_score {

	 regress `i' treatment if ptsbl_overall_score != ., cluster(school_no)

	matrix ORI2_`i'_temp = r(table)
	matrix ORI2_`i'_r2 = e(r2)
	matrix ORI2_`i'_obs = e(N)

	 cgmwildboot_2 `i' treatment if ptsbl_overall_score != ., cluster(school_no) bootcluster(school_no) null(0) reps(999) seed(1)
	matrix ORI2_`i'_temp_p = e(Pvals)

	
	foreach s in be se pv rpv wpv {
		matrix ORI2_`i'_`s' = J(7,1,.)
	}

	foreach j in 1 2 3 4 5 6 7 {
		* beta
		matrix ORI2_`i'_be[`j',1] = ORI2_`i'_temp[1,`j']
		* standard error
		matrix ORI2_`i'_se[`j',1] = ORI2_`i'_temp[2,`j']
		* p value
		matrix ORI2_`i'_pv[`j',1] = ORI2_`i'_temp[4,`j']
		matrix ORI2_`i'_wpv[`j',1] = ORI2_`i'_temp_p[`j',1]
	}

*	cgmwildboot `i' treatment wrongDT cheating wrongTshort wrongTlong dum_grade, ///
*	cluster(school_no) bootcluster(school_no) null(0 . . . . . ) reps(999) seed(1)


	
}




foreach i in rosen cpcs {

	 regress `i'_el treatment if `i'_bl != ., cluster(school_no)

	matrix ORI2_`i'_el_temp = r(table)
	matrix ORI2_`i'_el_r2 = e(r2)
	matrix ORI2_`i'_el_obs = e(N)

	 cgmwildboot_2 `i'_el treatment if `i'_bl != ., cluster(school_no) bootcluster(school_no) null(0) reps(999) seed(1)
	matrix ORI2_`i'_el_temp_p = e(Pvals)

	
	foreach s in be se pv rpv wpv {
		matrix ORI2_`i'_el_`s' = J(7,1,.)
	}

	foreach j in 1 2 3 4 5 6 7 {
		* beta
		matrix ORI2_`i'_el_be[`j',1] = ORI2_`i'_el_temp[1,`j']
		* standard error
		matrix ORI2_`i'_el_se[`j',1] = ORI2_`i'_el_temp[2,`j']
		* p value
		matrix ORI2_`i'_el_pv[`j',1] = ORI2_`i'_el_temp[4,`j']
		matrix ORI2_`i'_el_wpv[`j',1] = ORI2_`i'_el_temp_p[`j',1]
	}

*	cgmwildboot `i' treatment wrongDT cheating wrongTshort wrongTlong dum_grade, ///
*	cluster(school_no) bootcluster(school_no) null(0 . . . . . ) reps(999) seed(1)


	
}



foreach s in be se pv rpv r2 obs wpv {
	matrix ORI2_`s' = ORI2_DT_per_min_post_`s', ORI2_DT_score_post_`s', ///
	ORI2_DT_time_post_`s', ORI2_ptsel_overall_score_`s', ///
	ORI2_rosen_el_`s', ORI2_cpcs_el_`s'
}











preserve
drop if DT_per_min_pre == . | DT_score_pre == . | DT_time_pre == . | ///
ptsbl_overall_score == . | rosen_bl == . | cpcs_bl == . 

foreach i in DT_per_min DT_score DT_time  {

	 regress dif_`i' treatment, cluster(school_no)

	matrix ORI3_dif_`i'_temp = r(table)
	matrix ORI3_dif_`i'_r2 = e(r2)
	matrix ORI3_dif_`i'_obs = e(N)

	 cgmwildboot_2 dif_`i' treatment, cluster(school_no) bootcluster(school_no) null(0) reps(999) seed(1)
	matrix ORI3_dif_`i'_temp_p = e(Pvals)

	
	foreach s in be se pv rpv wpv {
		matrix ORI3_dif_`i'_`s' = J(7,1,.)
	}

	foreach j in 1 2 3 4 5 6 7 {
		* beta
		matrix ORI3_dif_`i'_be[`j',1] = ORI3_dif_`i'_temp[1,`j']
		* standard error
		matrix ORI3_dif_`i'_se[`j',1] = ORI3_dif_`i'_temp[2,`j']
		* p value
		matrix ORI3_dif_`i'_pv[`j',1] = ORI3_dif_`i'_temp[4,`j']
		matrix ORI3_dif_`i'_wpv[`j',1] = ORI3_dif_`i'_temp_p[`j',1]
	}

*	cgmwildboot `i' treatment wrongDT cheating wrongTshort wrongTlong dum_grade, ///
*	cluster(school_no) bootcluster(school_no) null(0 . . . . . ) reps(999) seed(1)


	
}

foreach i in dif_PTS_cog {

	 regress `i' treatment, cluster(school_no)

	matrix ORI3_`i'_temp = r(table)
	matrix ORI3_`i'_r2 = e(r2)
	matrix ORI3_`i'_obs = e(N)

	 cgmwildboot_2 `i' treatment, cluster(school_no) bootcluster(school_no) null(0) reps(999) seed(1)
	matrix ORI3_`i'_temp_p = e(Pvals)

	
	foreach s in be se pv rpv wpv {
		matrix ORI3_`i'_`s' = J(7,1,.)
	}

	foreach j in 1 2 3 4 5 6 7 {
		* beta
		matrix ORI3_`i'_be[`j',1] = ORI3_`i'_temp[1,`j']
		* standard error
		matrix ORI3_`i'_se[`j',1] = ORI3_`i'_temp[2,`j']
		* p value
		matrix ORI3_`i'_pv[`j',1] = ORI3_`i'_temp[4,`j']
		matrix ORI3_`i'_wpv[`j',1] = ORI3_`i'_temp_p[`j',1]
	}

*	cgmwildboot `i' treatment wrongDT cheating wrongTshort wrongTlong dum_grade, ///
*	cluster(school_no) bootcluster(school_no) null(0 . . . . . ) reps(999) seed(1)


	
}




foreach i in rosen cpcs {

	 regress dif_`i' treatment, cluster(school_no)

	matrix ORI3_dif_`i'_temp = r(table)
	matrix ORI3_dif_`i'_r2 = e(r2)
	matrix ORI3_dif_`i'_obs = e(N)

	 cgmwildboot_2 dif_`i' treatment, cluster(school_no) bootcluster(school_no) null(0) reps(999) seed(1)
	matrix ORI3_dif_`i'_temp_p = e(Pvals)

	
	foreach s in be se pv rpv wpv {
		matrix ORI3_dif_`i'_`s' = J(7,1,.)
	}

	foreach j in 1 2 3 4 5 6 7 {
		* beta
		matrix ORI3_dif_`i'_be[`j',1] = ORI3_dif_`i'_temp[1,`j']
		* standard error
		matrix ORI3_dif_`i'_se[`j',1] = ORI3_dif_`i'_temp[2,`j']
		* p value
		matrix ORI3_dif_`i'_pv[`j',1] = ORI3_dif_`i'_temp[4,`j']
		matrix ORI3_dif_`i'_wpv[`j',1] = ORI3_dif_`i'_temp_p[`j',1]
	}

*	cgmwildboot `i' treatment wrongDT cheating wrongTshort wrongTlong dum_grade, ///
*	cluster(school_no) bootcluster(school_no) null(0 . . . . . ) reps(999) seed(1)


	
}



************** Multiple testing (rwolf_2)
*log using "temp/rwolf_2.log"
rwolf_2 dif_DT_per_min dif_DT_score dif_DT_time dif_PTS_cog ///
dif_rosen dif_cpcs, ///
indepvar(treatment) cluster(school_no) vce(cluster school_no)

foreach i in dif_DT_per_min dif_DT_score dif_DT_time dif_PTS_cog ///
dif_rosen dif_cpcs {
	matrix ORI3_`i'_rpv[1,1] = e(rw_`i')
}

foreach s in be se pv rpv r2 obs wpv {
	matrix ORI3_`s' = ORI3_dif_DT_per_min_`s', ORI3_dif_DT_score_`s', ///
	ORI3_dif_DT_time_`s', ORI3_dif_PTS_cog_`s', ///
	ORI3_dif_rosen_`s', ORI3_dif_cpcs_`s'
}








foreach i in DT_per_min DT_score DT_time  {

	 regress `i'_post treatment, cluster(school_no)

	matrix ORI4_`i'_post_temp = r(table)
	matrix ORI4_`i'_post_r2 = e(r2)
	matrix ORI4_`i'_post_obs = e(N)

	 cgmwildboot_2 `i'_post treatment, cluster(school_no) bootcluster(school_no) null(0) reps(999) seed(1)
	matrix ORI4_`i'_post_temp_p = e(Pvals)

	
	foreach s in be se pv rpv wpv {
		matrix ORI4_`i'_post_`s' = J(7,1,.)
	}

	foreach j in 1 2 3 4 5 6 7 {
		* beta
		matrix ORI4_`i'_post_be[`j',1] = ORI4_`i'_post_temp[1,`j']
		* standard error
		matrix ORI4_`i'_post_se[`j',1] = ORI4_`i'_post_temp[2,`j']
		* p value
		matrix ORI4_`i'_post_pv[`j',1] = ORI4_`i'_post_temp[4,`j']
		matrix ORI4_`i'_post_wpv[`j',1] = ORI4_`i'_post_temp_p[`j',1]
	}

*	cgmwildboot `i' treatment wrongDT cheating wrongTshort wrongTlong dum_grade, ///
*	cluster(school_no) bootcluster(school_no) null(0 . . . . . ) reps(999) seed(1)


	
}

foreach i in ptsel_overall_score {

	 regress `i' treatment, cluster(school_no)

	matrix ORI4_`i'_temp = r(table)
	matrix ORI4_`i'_r2 = e(r2)
	matrix ORI4_`i'_obs = e(N)

	 cgmwildboot_2 `i' treatment, cluster(school_no) bootcluster(school_no) null(0) reps(999) seed(1)
	matrix ORI4_`i'_temp_p = e(Pvals)

	
	foreach s in be se pv rpv wpv {
		matrix ORI4_`i'_`s' = J(7,1,.)
	}

	foreach j in 1 2 3 4 5 6 7 {
		* beta
		matrix ORI4_`i'_be[`j',1] = ORI4_`i'_temp[1,`j']
		* standard error
		matrix ORI4_`i'_se[`j',1] = ORI4_`i'_temp[2,`j']
		* p value
		matrix ORI4_`i'_pv[`j',1] = ORI4_`i'_temp[4,`j']
		matrix ORI4_`i'_wpv[`j',1] = ORI4_`i'_temp_p[`j',1]
	}

*	cgmwildboot `i' treatment wrongDT cheating wrongTshort wrongTlong dum_grade, ///
*	cluster(school_no) bootcluster(school_no) null(0 . . . . . ) reps(999) seed(1)


	
}




foreach i in rosen cpcs {

	 regress `i'_el treatment, cluster(school_no)

	matrix ORI4_`i'_el_temp = r(table)
	matrix ORI4_`i'_el_r2 = e(r2)
	matrix ORI4_`i'_el_obs = e(N)

	 cgmwildboot_2 `i'_el treatment, cluster(school_no) bootcluster(school_no) null(0) reps(999) seed(1)
	matrix ORI4_`i'_el_temp_p = e(Pvals)

	
	foreach s in be se pv rpv wpv {
		matrix ORI4_`i'_el_`s' = J(7,1,.)
	}

	foreach j in 1 2 3 4 5 6 7 {
		* beta
		matrix ORI4_`i'_el_be[`j',1] = ORI4_`i'_el_temp[1,`j']
		* standard error
		matrix ORI4_`i'_el_se[`j',1] = ORI4_`i'_el_temp[2,`j']
		* p value
		matrix ORI4_`i'_el_pv[`j',1] = ORI4_`i'_el_temp[4,`j']
		matrix ORI4_`i'_el_wpv[`j',1] = ORI4_`i'_el_temp_p[`j',1]
	}

*	cgmwildboot `i' treatment wrongDT cheating wrongTshort wrongTlong dum_grade, ///
*	cluster(school_no) bootcluster(school_no) null(0 . . . . . ) reps(999) seed(1)


	
}





************** Multiple testing (rwolf_2)
*log using "temp/rwolf_2.log"
rwolf_2 DT_per_min_post DT_score_post DT_time_post ptsel_overall_score rosen_el ///
cpcs_el, ///
indepvar(treatment) cluster(school_no) vce(cluster school_no)

matrix ORI4_DT_per_min_post_rpv[1,1] = e(rw_DT_per_min_post)
matrix ORI4_DT_score_post_rpv[1,1] = e(rw_DT_score_post)
matrix ORI4_DT_time_post_rpv[1,1] = e(rw_DT_time_post)
matrix ORI4_ptsel_overall_score_rpv[1,1] = e(rw_ptsel_overall_score)
matrix ORI4_rosen_el_rpv[1,1] = e(rw_rosen_el)
matrix ORI4_cpcs_el_rpv[1,1] = e(rw_cpcs_el)





foreach s in be se pv rpv r2 obs wpv {
	matrix ORI4_`s' = ORI4_DT_per_min_post_`s', ORI4_DT_score_post_`s', ///
	ORI4_DT_time_post_`s', ORI4_ptsel_overall_score_`s', ///
	ORI4_rosen_el_`s', ORI4_cpcs_el_`s'
}





restore






















*** ANCOVA Specifications (table E2 panel B)



foreach i in DT_per_min DT_score DT_time {

gen dif_`i'_WDT = dif_`i'
replace  dif_`i'_WDT = . if wrongDT == 1
}


foreach i in DT_per_min_post DT_score_post DT_time_post {

gen `i'_WDT = `i'
replace  `i'_WDT = . if wrongDT == 1
}




foreach i in DT_per_min DT_score DT_time  {

	 regress `i'_post_WDT treatment `i'_pre if `i'_pre != . , cluster(school_no)

	matrix ANC1_`i'_post_temp = r(table)
	matrix ANC1_`i'_post_r2 = e(r2)
	matrix ANC1_`i'_post_obs = e(N)

	  cgmwildboot_2 `i'_post_WDT treatment `i'_pre if `i'_pre != . , cluster(school_no) bootcluster(school_no) null(0 .) reps(999) seed(1)
	matrix ANC1_`i'_post_temp_p = e(Pvals)

	
	foreach s in be se pv rpv wpv {
		matrix ANC1_`i'_post_`s' = J(7,1,.)
	}

	foreach j in 1 2 3 4 5 6 7 {
		* beta
		matrix ANC1_`i'_post_be[`j',1] = ANC1_`i'_post_temp[1,`j']
		* standard error
		matrix ANC1_`i'_post_se[`j',1] = ANC1_`i'_post_temp[2,`j']
		* p value
		matrix ANC1_`i'_post_pv[`j',1] = ANC1_`i'_post_temp[4,`j']
		matrix ANC1_`i'_post_wpv[`j',1] = ANC1_`i'_post_temp_p[`j',1]
	}

*	cgmwildboot `i' treatment wrongDT cheating wrongTshort wrongTlong dum_grade, ///
*	cluster(school_no) bootcluster(school_no) null(0 . . . . . ) reps(999) seed(1)


	
}

foreach i in ptsel_overall_score {

	 regress `i' treatment ptsbl_overall_score if ptsbl_overall_score != ., cluster(school_no)

	matrix ANC1_`i'_temp = r(table)
	matrix ANC1_`i'_r2 = e(r2)
	matrix ANC1_`i'_obs = e(N)

	  cgmwildboot_2 `i' treatment ptsbl_overall_score if ptsbl_overall_score != ., cluster(school_no) bootcluster(school_no) null(0 .) reps(999) seed(1)
	matrix ANC1_`i'_temp_p = e(Pvals)

	
	foreach s in be se pv rpv wpv {
		matrix ANC1_`i'_`s' = J(7,1,.)
	}

	foreach j in 1 2 3 4 5 6 7 {
		* beta
		matrix ANC1_`i'_be[`j',1] = ANC1_`i'_temp[1,`j']
		* standard error
		matrix ANC1_`i'_se[`j',1] = ANC1_`i'_temp[2,`j']
		* p value
		matrix ANC1_`i'_pv[`j',1] = ANC1_`i'_temp[4,`j']
		matrix ANC1_`i'_wpv[`j',1] = ANC1_`i'_temp_p[`j',1]
	}

*	cgmwildboot `i' treatment wrongDT cheating wrongTshort wrongTlong dum_grade, ///
*	cluster(school_no) bootcluster(school_no) null(0 . . . . . ) reps(999) seed(1)


	
}




foreach i in rosen cpcs {

	 regress `i'_el treatment `i'_bl if `i'_bl != ., cluster(school_no)

	matrix ANC1_`i'_el_temp = r(table)
	matrix ANC1_`i'_el_r2 = e(r2)
	matrix ANC1_`i'_el_obs = e(N)

	  cgmwildboot_2 `i'_el treatment `i'_bl if `i'_bl != ., cluster(school_no) bootcluster(school_no) null(0 .) reps(999) seed(1)
	matrix ANC1_`i'_el_temp_p = e(Pvals)

	
	foreach s in be se pv rpv wpv {
		matrix ANC1_`i'_el_`s' = J(7,1,.)
	}

	foreach j in 1 2 3 4 5 6 7 {
		* beta
		matrix ANC1_`i'_el_be[`j',1] = ANC1_`i'_el_temp[1,`j']
		* standard error
		matrix ANC1_`i'_el_se[`j',1] = ANC1_`i'_el_temp[2,`j']
		* p value
		matrix ANC1_`i'_el_pv[`j',1] = ANC1_`i'_el_temp[4,`j']
		matrix ANC1_`i'_el_wpv[`j',1] = ANC1_`i'_el_temp_p[`j',1]
	}

*	cgmwildboot `i' treatment wrongDT cheating wrongTshort wrongTlong dum_grade, ///
*	cluster(school_no) bootcluster(school_no) null(0 . . . . . ) reps(999) seed(1)


	
}



foreach s in be se pv rpv r2 obs wpv {
	matrix ANC1_`s' = ANC1_DT_per_min_post_`s', ANC1_DT_score_post_`s', ///
	ANC1_DT_time_post_`s', ANC1_ptsel_overall_score_`s', ///
	ANC1_rosen_el_`s', ANC1_cpcs_el_`s'
}









*** First difference (Table E2 panel C)


foreach i in DT_per_min DT_score DT_time  {

	 regress dif_`i'_WDT treatment if `i'_pre != . , cluster(school_no)

	matrix ALa01_dif_`i'_temp = r(table)
	matrix ALa01_dif_`i'_r2 = e(r2)
	matrix ALa01_dif_`i'_obs = e(N)

	  cgmwildboot_2 dif_`i'_WDT treatment if `i'_pre != . , cluster(school_no) bootcluster(school_no) null(0) reps(999) seed(1)
	matrix ALa01_dif_`i'_temp_p = e(Pvals)

	
	foreach s in be se pv rpv wpv {
		matrix ALa01_dif_`i'_`s' = J(7,1,.)
	}

	foreach j in 1 2 3 4 5 6 7 {
		* beta
		matrix ALa01_dif_`i'_be[`j',1] = ALa01_dif_`i'_temp[1,`j']
		* standard error
		matrix ALa01_dif_`i'_se[`j',1] = ALa01_dif_`i'_temp[2,`j']
		* p value
		matrix ALa01_dif_`i'_pv[`j',1] = ALa01_dif_`i'_temp[4,`j']
		matrix ALa01_dif_`i'_wpv[`j',1] = ALa01_dif_`i'_temp_p[`j',1]
	}

*	cgmwildboot `i' treatment wrongDT cheating wrongTshort wrongTlong dum_grade, ///
*	cluster(school_no) bootcluster(school_no) null(0 . . . . . ) reps(999) seed(1)


	
}

foreach i in dif_PTS_cog {

	 regress `i' treatment if ptsbl_overall_score != . , cluster(school_no)

	matrix ALa01_`i'_temp = r(table)
	matrix ALa01_`i'_r2 = e(r2)
	matrix ALa01_`i'_obs = e(N)

	  cgmwildboot_2 `i' treatment if ptsbl_overall_score != . , cluster(school_no) bootcluster(school_no) null(0) reps(999) seed(1)
	matrix ALa01_`i'_temp_p = e(Pvals)

	
	foreach s in be se pv rpv wpv {
		matrix ALa01_`i'_`s' = J(7,1,.)
	}

	foreach j in 1 2 3 4 5 6 7 {
		* beta
		matrix ALa01_`i'_be[`j',1] = ALa01_`i'_temp[1,`j']
		* standard error
		matrix ALa01_`i'_se[`j',1] = ALa01_`i'_temp[2,`j']
		* p value
		matrix ALa01_`i'_pv[`j',1] = ALa01_`i'_temp[4,`j']
		matrix ALa01_`i'_wpv[`j',1] = ALa01_`i'_temp_p[`j',1]
	}

*	cgmwildboot `i' treatment wrongDT cheating wrongTshort wrongTlong dum_grade, ///
*	cluster(school_no) bootcluster(school_no) null(0 . . . . . ) reps(999) seed(1)


	
}




foreach i in rosen cpcs {

	 regress dif_`i' treatment if `i'_bl != . , cluster(school_no)

	matrix ALa01_dif_`i'_temp = r(table)
	matrix ALa01_dif_`i'_r2 = e(r2)
	matrix ALa01_dif_`i'_obs = e(N)

	  cgmwildboot_2 dif_`i' treatment if `i'_bl != . , cluster(school_no) bootcluster(school_no) null(0) reps(999) seed(1)
	matrix ALa01_dif_`i'_temp_p = e(Pvals)

	
	foreach s in be se pv rpv wpv {
		matrix ALa01_dif_`i'_`s' = J(7,1,.)
	}

	foreach j in 1 2 3 4 5 6 7 {
		* beta
		matrix ALa01_dif_`i'_be[`j',1] = ALa01_dif_`i'_temp[1,`j']
		* standard error
		matrix ALa01_dif_`i'_se[`j',1] = ALa01_dif_`i'_temp[2,`j']
		* p value
		matrix ALa01_dif_`i'_pv[`j',1] = ALa01_dif_`i'_temp[4,`j']
		matrix ALa01_dif_`i'_wpv[`j',1] = ALa01_dif_`i'_temp_p[`j',1]
	}

*	cgmwildboot `i' treatment wrongDT cheating wrongTshort wrongTlong dum_grade, ///
*	cluster(school_no) bootcluster(school_no) null(0 . . . . . ) reps(999) seed(1)


	
}



rwolf_2 dif_DT_per_min_WDT dif_DT_score_WDT ///
dif_DT_time_WDT dif_PTS_cog dif_rosen ///
dif_cpcs, ///
indepvar(treatment) cluster(school_no) vce(cluster school_no)


matrix ALa01_dif_DT_per_min_rpv[1,1] = e(rw_dif_DT_per_min_WDT)
matrix ALa01_dif_DT_score_rpv[1,1] = e(rw_dif_DT_score_WDT)
matrix ALa01_dif_DT_time_rpv[1,1] = e(rw_dif_DT_time_WDT)
matrix ALa01_dif_PTS_cog_rpv[1,1] = e(rw_dif_PTS_cog)
matrix ALa01_dif_rosen_rpv[1,1] = e(rw_dif_rosen)
matrix ALa01_dif_cpcs_rpv[1,1] = e(rw_dif_cpcs)




foreach s in be se pv r2 rpv obs wpv {
	matrix ALa01_`s' = ALa01_dif_DT_per_min_`s', ALa01_dif_DT_score_`s', ///
	ALa01_dif_DT_time_`s', ALa01_dif_PTS_cog_`s', ///
	ALa01_dif_rosen_`s', ALa01_dif_cpcs_`s'
}








*** Endline (Table E2 panel A)



foreach i in DT_per_min DT_score DT_time  {

	 regress `i'_post_WDT treatment if `i'_pre != . , cluster(school_no)

	matrix ALa02_`i'_post_temp = r(table)
	matrix ALa02_`i'_post_r2 = e(r2)
	matrix ALa02_`i'_post_obs = e(N)

	  cgmwildboot_2 `i'_post_WDT treatment if `i'_pre != . , cluster(school_no) bootcluster(school_no) null(0) reps(999) seed(1)
	matrix ALa02_`i'_post_temp_p = e(Pvals)

	
	foreach s in be se pv rpv wpv {
		matrix ALa02_`i'_post_`s' = J(7,1,.)
	}

	foreach j in 1 2 3 4 5 6 7 {
		* beta
		matrix ALa02_`i'_post_be[`j',1] = ALa02_`i'_post_temp[1,`j']
		* standard error
		matrix ALa02_`i'_post_se[`j',1] = ALa02_`i'_post_temp[2,`j']
		* p value
		matrix ALa02_`i'_post_pv[`j',1] = ALa02_`i'_post_temp[4,`j']
		matrix ALa02_`i'_post_wpv[`j',1] = ALa02_`i'_post_temp_p[`j',1]
	}

*	cgmwildboot `i' treatment wrongDT cheating wrongTshort wrongTlong dum_grade, ///
*	cluster(school_no) bootcluster(school_no) null(0 . . . . . ) reps(999) seed(1)


	
}

foreach i in ptsel_overall_score {

	 regress `i' treatment if ptsbl_overall_score != . , cluster(school_no)

	matrix ALa02_`i'_temp = r(table)
	matrix ALa02_`i'_r2 = e(r2)
	matrix ALa02_`i'_obs = e(N)

	  cgmwildboot_2 `i' treatment if ptsbl_overall_score != . , cluster(school_no) bootcluster(school_no) null(0) reps(999) seed(1)
	matrix ALa02_`i'_temp_p = e(Pvals)

	
	foreach s in be se pv rpv wpv {
		matrix ALa02_`i'_`s' = J(7,1,.)
	}

	foreach j in 1 2 3 4 5 6 7 {
		* beta
		matrix ALa02_`i'_be[`j',1] = ALa02_`i'_temp[1,`j']
		* standard error
		matrix ALa02_`i'_se[`j',1] = ALa02_`i'_temp[2,`j']
		* p value
		matrix ALa02_`i'_pv[`j',1] = ALa02_`i'_temp[4,`j']
		matrix ALa02_`i'_wpv[`j',1] = ALa02_`i'_temp_p[`j',1]
	}

*	cgmwildboot `i' treatment wrongDT cheating wrongTshort wrongTlong dum_grade, ///
*	cluster(school_no) bootcluster(school_no) null(0 . . . . . ) reps(999) seed(1)


	
}




foreach i in rosen cpcs {

	 regress `i'_el treatment if `i'_bl != . , cluster(school_no)

	matrix ALa02_`i'_el_temp = r(table)
	matrix ALa02_`i'_el_r2 = e(r2)
	matrix ALa02_`i'_el_obs = e(N)

	  cgmwildboot_2 `i'_el treatment if `i'_bl != . , cluster(school_no) bootcluster(school_no) null(0) reps(999) seed(1)
	matrix ALa02_`i'_el_temp_p = e(Pvals)

	
	foreach s in be se pv rpv wpv {
		matrix ALa02_`i'_el_`s' = J(7,1,.)
	}

	foreach j in 1 2 3 4 5 6 7 {
		* beta
		matrix ALa02_`i'_el_be[`j',1] = ALa02_`i'_el_temp[1,`j']
		* standard error
		matrix ALa02_`i'_el_se[`j',1] = ALa02_`i'_el_temp[2,`j']
		* p value
		matrix ALa02_`i'_el_pv[`j',1] = ALa02_`i'_el_temp[4,`j']
		matrix ALa02_`i'_el_wpv[`j',1] = ALa02_`i'_el_temp_p[`j',1]
	}

*	cgmwildboot `i' treatment wrongDT cheating wrongTshort wrongTlong dum_grade, ///
*	cluster(school_no) bootcluster(school_no) null(0 . . . . . ) reps(999) seed(1)


	
}




rwolf_2 DT_per_min_post_WDT DT_score_post_WDT ///
DT_time_post_WDT ptsel_overall_score rosen_el ///
cpcs_el, ///
indepvar(treatment) cluster(school_no) vce(cluster school_no)


matrix ALa02_DT_per_min_post_rpv[1,1] = e(rw_DT_per_min_post_WDT)
matrix ALa02_DT_score_post_rpv[1,1] = e(rw_DT_score_post_WDT)
matrix ALa02_DT_time_post_rpv[1,1] = e(rw_DT_time_post_WDT)
matrix ALa02_ptsel_overall_score_rpv[1,1] = e(rw_ptsel_overall_score)
matrix ALa02_rosen_el_rpv[1,1] = e(rw_rosen_el)
matrix ALa02_cpcs_el_rpv[1,1] = e(rw_cpcs_el)



foreach s in be se pv rpv r2 obs wpv {
	matrix ALa02_`s' = ALa02_DT_per_min_post_`s', ALa02_DT_score_post_`s', ///
	ALa02_DT_time_post_`s', ALa02_ptsel_overall_score_`s', ///
	ALa02_rosen_el_`s', ALa02_cpcs_el_`s'
}
















*** Endline (Table E2 panel A)




foreach i in DT_per_min DT_score DT_time  {

	 regress `i'_post treatment if `i'_pre != . & wrongDT == 0, cluster(school_no)

	matrix ALa2_`i'_post_temp = r(table)
	matrix ALa2_`i'_post_r2 = e(r2)
	matrix ALa2_`i'_post_obs = e(N)

	  cgmwildboot_2 `i'_post treatment if `i'_pre != . & wrongDT == 0, cluster(school_no) bootcluster(school_no) null(0) reps(999) seed(1)
	matrix ALa2_`i'_post_temp_p = e(Pvals)

	
	foreach s in be se pv rpv wpv {
		matrix ALa2_`i'_post_`s' = J(7,1,.)
	}

	foreach j in 1 2 3 4 5 6 7 {
		* beta
		matrix ALa2_`i'_post_be[`j',1] = ALa2_`i'_post_temp[1,`j']
		* standard error
		matrix ALa2_`i'_post_se[`j',1] = ALa2_`i'_post_temp[2,`j']
		* p value
		matrix ALa2_`i'_post_pv[`j',1] = ALa2_`i'_post_temp[4,`j']
		matrix ALa2_`i'_post_wpv[`j',1] = ALa2_`i'_post_temp_p[`j',1]
	}

*	cgmwildboot `i' treatment wrongDT cheating wrongTshort wrongTlong dum_grade, ///
*	cluster(school_no) bootcluster(school_no) null(0 . . . . . ) reps(999) seed(1)


	
}

foreach i in ptsel_overall_score {

	 regress `i' treatment if ptsbl_overall_score != . & wrongDT == 0, cluster(school_no)

	matrix ALa2_`i'_temp = r(table)
	matrix ALa2_`i'_r2 = e(r2)
	matrix ALa2_`i'_obs = e(N)

	  cgmwildboot_2 `i' treatment if ptsbl_overall_score != . & wrongDT == 0, cluster(school_no) bootcluster(school_no) null(0) reps(999) seed(1)
	matrix ALa2_`i'_temp_p = e(Pvals)

	
	foreach s in be se pv rpv wpv {
		matrix ALa2_`i'_`s' = J(7,1,.)
	}

	foreach j in 1 2 3 4 5 6 7 {
		* beta
		matrix ALa2_`i'_be[`j',1] = ALa2_`i'_temp[1,`j']
		* standard error
		matrix ALa2_`i'_se[`j',1] = ALa2_`i'_temp[2,`j']
		* p value
		matrix ALa2_`i'_pv[`j',1] = ALa2_`i'_temp[4,`j']
		matrix ALa2_`i'_wpv[`j',1] = ALa2_`i'_temp_p[`j',1]
	}

*	cgmwildboot `i' treatment wrongDT cheating wrongTshort wrongTlong dum_grade, ///
*	cluster(school_no) bootcluster(school_no) null(0 . . . . . ) reps(999) seed(1)


	
}




foreach i in rosen cpcs {

	 regress `i'_el treatment if `i'_bl != . & wrongDT == 0, cluster(school_no)

	matrix ALa2_`i'_el_temp = r(table)
	matrix ALa2_`i'_el_r2 = e(r2)
	matrix ALa2_`i'_el_obs = e(N)

	  cgmwildboot_2 `i'_el treatment if `i'_bl != . & wrongDT == 0, cluster(school_no) bootcluster(school_no) null(0) reps(999) seed(1)
	matrix ALa2_`i'_el_temp_p = e(Pvals)

	
	foreach s in be se pv rpv wpv {
		matrix ALa2_`i'_el_`s' = J(7,1,.)
	}

	foreach j in 1 2 3 4 5 6 7 {
		* beta
		matrix ALa2_`i'_el_be[`j',1] = ALa2_`i'_el_temp[1,`j']
		* standard error
		matrix ALa2_`i'_el_se[`j',1] = ALa2_`i'_el_temp[2,`j']
		* p value
		matrix ALa2_`i'_el_pv[`j',1] = ALa2_`i'_el_temp[4,`j']
		matrix ALa2_`i'_el_wpv[`j',1] = ALa2_`i'_el_temp_p[`j',1]
	}

*	cgmwildboot `i' treatment wrongDT cheating wrongTshort wrongTlong dum_grade, ///
*	cluster(school_no) bootcluster(school_no) null(0 . . . . . ) reps(999) seed(1)


	
}




foreach s in be se pv rpv r2 obs wpv {
	matrix ALa2_`s' = ALa2_DT_per_min_post_`s', ALa2_DT_score_post_`s', ///
	ALa2_DT_time_post_`s', ALa2_ptsel_overall_score_`s', ///
	ALa2_rosen_el_`s', ALa2_cpcs_el_`s'
}











*** Endline (Table 2 panel A and E1 panel A)





foreach i in DT_per_min DT_score DT_time  {

	 regress `i'_post treatment, cluster(school_no)

	matrix ALa4_`i'_post_temp = r(table)
	matrix ALa4_`i'_post_r2 = e(r2)
	matrix ALa4_`i'_post_obs = e(N)

	  cgmwildboot_2 `i'_post treatment, cluster(school_no) bootcluster(school_no) null(0) reps(999) seed(1)
	matrix ALa4_`i'_post_temp_p = e(Pvals)

	
	foreach s in be se pv rpv wpv {
		matrix ALa4_`i'_post_`s' = J(7,1,.)
	}

	foreach j in 1 2 3 4 5 6 7 {
		* beta
		matrix ALa4_`i'_post_be[`j',1] = ALa4_`i'_post_temp[1,`j']
		* standard error
		matrix ALa4_`i'_post_se[`j',1] = ALa4_`i'_post_temp[2,`j']
		* p value
		matrix ALa4_`i'_post_pv[`j',1] = ALa4_`i'_post_temp[4,`j']
		matrix ALa4_`i'_post_wpv[`j',1] = ALa4_`i'_post_temp_p[`j',1]
	}

*	cgmwildboot `i' treatment wrongDT cheating wrongTshort wrongTlong dum_grade, ///
*	cluster(school_no) bootcluster(school_no) null(0 . . . . . ) reps(999) seed(1)


	
}

foreach i in ptsel_overall_score {

	 regress `i' treatment, cluster(school_no)

	matrix ALa4_`i'_temp = r(table)
	matrix ALa4_`i'_r2 = e(r2)
	matrix ALa4_`i'_obs = e(N)

	  cgmwildboot_2 `i' treatment, cluster(school_no) bootcluster(school_no) null(0) reps(999) seed(1)
	matrix ALa4_`i'_temp_p = e(Pvals)

	
	foreach s in be se pv rpv wpv {
		matrix ALa4_`i'_`s' = J(7,1,.)
	}

	foreach j in 1 2 3 4 5 6 7 {
		* beta
		matrix ALa4_`i'_be[`j',1] = ALa4_`i'_temp[1,`j']
		* standard error
		matrix ALa4_`i'_se[`j',1] = ALa4_`i'_temp[2,`j']
		* p value
		matrix ALa4_`i'_pv[`j',1] = ALa4_`i'_temp[4,`j']
		matrix ALa4_`i'_wpv[`j',1] = ALa4_`i'_temp_p[`j',1]
	}

*	cgmwildboot `i' treatment wrongDT cheating wrongTshort wrongTlong dum_grade, ///
*	cluster(school_no) bootcluster(school_no) null(0 . . . . . ) reps(999) seed(1)


	
}




foreach i in rosen cpcs {

	 regress `i'_el treatment, cluster(school_no)

	matrix ALa4_`i'_el_temp = r(table)
	matrix ALa4_`i'_el_r2 = e(r2)
	matrix ALa4_`i'_el_obs = e(N)

	  cgmwildboot_2 `i'_el treatment, cluster(school_no) bootcluster(school_no) null(0) reps(999) seed(1)
	matrix ALa4_`i'_el_temp_p = e(Pvals)

	
	foreach s in be se pv rpv wpv {
		matrix ALa4_`i'_el_`s' = J(7,1,.)
	}

	foreach j in 1 2 3 4 5 6 7 {
		* beta
		matrix ALa4_`i'_el_be[`j',1] = ALa4_`i'_el_temp[1,`j']
		* standard error
		matrix ALa4_`i'_el_se[`j',1] = ALa4_`i'_el_temp[2,`j']
		* p value
		matrix ALa4_`i'_el_pv[`j',1] = ALa4_`i'_el_temp[4,`j']
		matrix ALa4_`i'_el_wpv[`j',1] = ALa4_`i'_el_temp_p[`j',1]
	}

*	cgmwildboot `i' treatment wrongDT cheating wrongTshort wrongTlong dum_grade, ///
*	cluster(school_no) bootcluster(school_no) null(0 . . . . . ) reps(999) seed(1)


	
}




************** Multiple testing (rwolf_2)
*log using "temp/rwolf_2.log"
rwolf_2 DT_per_min_post DT_score_post DT_time_post ptsel_overall_score rosen_el ///
cpcs_el, ///
indepvar(treatment) cluster(school_no) vce(cluster school_no)



matrix ALa4_DT_per_min_post_rpv[1,1] = e(rw_DT_per_min_post)
matrix ALa4_DT_score_post_rpv[1,1] = e(rw_DT_score_post)
matrix ALa4_DT_time_post_rpv[1,1] = e(rw_DT_time_post)
matrix ALa4_ptsel_overall_score_rpv[1,1] = e(rw_ptsel_overall_score)
matrix ALa4_rosen_el_rpv[1,1] = e(rw_rosen_el)
matrix ALa4_cpcs_el_rpv[1,1] = e(rw_cpcs_el)






foreach s in be se pv rpv r2 obs wpv {
	matrix ALa4_`s' = ALa4_DT_per_min_post_`s', ALa4_DT_score_post_`s', ///
	ALa4_DT_time_post_`s', ALa4_ptsel_overall_score_`s', ///
	ALa4_rosen_el_`s', ALa4_cpcs_el_`s'
}








*** Endline (Table 2 panel A and E1 panel A)





foreach i in DT_per_min DT_score DT_time  {

	 regress `i'_post treatment if wrongDT == 0, cluster(school_no)

	matrix ALa5_`i'_post_temp = r(table)
	matrix ALa5_`i'_post_r2 = e(r2)
	matrix ALa5_`i'_post_obs = e(N)

	  cgmwildboot_2 `i'_post treatment if wrongDT == 0, cluster(school_no) bootcluster(school_no) null(0) reps(999) seed(1)
	matrix ALa5_`i'_post_temp_p = e(Pvals)

	
	foreach s in be se pv rpv wpv {
		matrix ALa5_`i'_post_`s' = J(7,1,.)
	}

	foreach j in 1 2 3 4 5 6 7 {
		* beta
		matrix ALa5_`i'_post_be[`j',1] = ALa5_`i'_post_temp[1,`j']
		* standard error
		matrix ALa5_`i'_post_se[`j',1] = ALa5_`i'_post_temp[2,`j']
		* p value
		matrix ALa5_`i'_post_pv[`j',1] = ALa5_`i'_post_temp[4,`j']
		matrix ALa5_`i'_post_wpv[`j',1] = ALa5_`i'_post_temp_p[`j',1]
	}

*	cgmwildboot `i' treatment wrongDT cheating wrongTshort wrongTlong dum_grade, ///
*	cluster(school_no) bootcluster(school_no) null(0 . . . . . ) reps(999) seed(1)


	
}

foreach i in ptsel_overall_score {

	 regress `i' treatment, cluster(school_no)

	matrix ALa5_`i'_temp = r(table)
	matrix ALa5_`i'_r2 = e(r2)
	matrix ALa5_`i'_obs = e(N)

	  cgmwildboot_2 `i' treatment, cluster(school_no) bootcluster(school_no) null(0) reps(999) seed(1)
	matrix ALa5_`i'_temp_p = e(Pvals)

	
	foreach s in be se pv rpv wpv {
		matrix ALa5_`i'_`s' = J(7,1,.)
	}

	foreach j in 1 2 3 4 5 6 7 {
		* beta
		matrix ALa5_`i'_be[`j',1] = ALa5_`i'_temp[1,`j']
		* standard error
		matrix ALa5_`i'_se[`j',1] = ALa5_`i'_temp[2,`j']
		* p value
		matrix ALa5_`i'_pv[`j',1] = ALa5_`i'_temp[4,`j']
		matrix ALa5_`i'_wpv[`j',1] = ALa5_`i'_temp_p[`j',1]
	}

*	cgmwildboot `i' treatment wrongDT cheating wrongTshort wrongTlong dum_grade, ///
*	cluster(school_no) bootcluster(school_no) null(0 . . . . . ) reps(999) seed(1)


	
}




foreach i in rosen cpcs {

	 regress `i'_el treatment, cluster(school_no)

	matrix ALa5_`i'_el_temp = r(table)
	matrix ALa5_`i'_el_r2 = e(r2)
	matrix ALa5_`i'_el_obs = e(N)

	  cgmwildboot_2 `i'_el treatment, cluster(school_no) bootcluster(school_no) null(0) reps(999) seed(1)
	matrix ALa5_`i'_el_temp_p = e(Pvals)

	
	foreach s in be se pv rpv wpv {
		matrix ALa5_`i'_el_`s' = J(7,1,.)
	}

	foreach j in 1 2 3 4 5 6 7 {
		* beta
		matrix ALa5_`i'_el_be[`j',1] = ALa5_`i'_el_temp[1,`j']
		* standard error
		matrix ALa5_`i'_el_se[`j',1] = ALa5_`i'_el_temp[2,`j']
		* p value
		matrix ALa5_`i'_el_pv[`j',1] = ALa5_`i'_el_temp[4,`j']
		matrix ALa5_`i'_el_wpv[`j',1] = ALa5_`i'_el_temp_p[`j',1]
	}

*	cgmwildboot `i' treatment wrongDT cheating wrongTshort wrongTlong dum_grade, ///
*	cluster(school_no) bootcluster(school_no) null(0 . . . . . ) reps(999) seed(1)


	
}



************** Multiple testing (rwolf_2)
*log using "temp/rwolf_2.log"
rwolf_2 DT_per_min_post DT_score_post DT_time_post ptsel_overall_score rosen_el ///
cpcs_el, ///
indepvar(treatment) cluster(school_no) vce(cluster school_no)



matrix ALa5_DT_per_min_post_rpv[1,1] = e(rw_DT_per_min_post)
matrix ALa5_DT_score_post_rpv[1,1] = e(rw_DT_score_post)
matrix ALa5_DT_time_post_rpv[1,1] = e(rw_DT_time_post)
matrix ALa5_ptsel_overall_score_rpv[1,1] = e(rw_ptsel_overall_score)
matrix ALa5_rosen_el_rpv[1,1] = e(rw_rosen_el)
matrix ALa5_cpcs_el_rpv[1,1] = e(rw_cpcs_el)






foreach s in be se pv rpv r2 obs wpv {
	matrix ALa5_`s' = ALa5_DT_per_min_post_`s', ALa5_DT_score_post_`s', ///
	ALa5_DT_time_post_`s', ALa5_ptsel_overall_score_`s', ///
	ALa5_rosen_el_`s', ALa5_cpcs_el_`s'
}























*** PSC data


sum math_score if grade==2
gen math_score_std = (math_score-r(mean))/r(sd) if grade==2
sum math_score if grade==4
replace math_score_std = (math_score-r(mean))/r(sd) if grade==4

gen dif_psc = math_score_std - ptsbl_overall_score

tab grade, gen(dum)
gen treatment_grade = treatment*dum1


sum Bangla if grade==2
gen Bangla_std = (Bangla-r(mean))/r(sd) if grade==2
sum Bangla if grade==4
replace Bangla_std = (Bangla-r(mean))/r(sd) if grade==4

gen dif_psc_Bangla = Bangla_std - ptsbl_overall_score



save "$path_data/data/temp/main_reg_data_psc.dta", replace










preserve

*** ANCOVA  (table E1 panel B -- only for DT related)

drop if wrongDT == 1

foreach i in DT_per_min DT_score DT_time {
gen `i'_pre_miss = `i'_pre
gen `i'_dum_miss = 0
replace `i'_dum_miss = 1 if `i'_pre == .
egen mean_`i'_pre = mean(`i'_pre)
replace `i'_pre_miss = mean_`i'_pre if `i'_pre == .
*replace `i'_pre_miss = 0 if `i'_pre == .
}




gen pts_pre_miss = ptsbl_overall_score
gen pts_dum_miss = 0
replace pts_dum_miss = 1 if ptsbl_overall_score == .
egen mean_pts_pre = mean(ptsbl_overall_score)
replace pts_pre_miss = mean_pts_pre if ptsbl_overall_score == .
*replace pts_pre_miss = 0 if ptsbl_overall_score == .





foreach i in rosen cpcs {
gen `i'_pre_miss = `i'_bl
gen `i'_dum_miss = 0
replace `i'_dum_miss = 1 if `i'_bl == .
egen mean_`i'_pre = mean(`i'_bl)
replace `i'_pre_miss = mean_`i'_pre if `i'_bl == .
*replace `i'_pre_miss = 0 if `i'_bl == .
}




foreach i in DT_per_min DT_score DT_time  {

	 regress `i'_post treatment `i'_pre_miss `i'_dum_miss, cluster(school_no)

	matrix ANC4_`i'_post_temp = r(table)
	matrix ANC4_`i'_post_r2 = e(r2)
	matrix ANC4_`i'_post_obs = e(N)

	  cgmwildboot_2 `i'_post treatment `i'_pre_miss `i'_dum_miss, cluster(school_no) bootcluster(school_no) null(0 . .) reps(999) seed(1)
	matrix ANC4_`i'_post_temp_p = e(Pvals)

	
	foreach s in be se pv rpv wpv {
		matrix ANC4_`i'_post_`s' = J(7,1,.)
	}

	foreach j in 1 2 3 4 5 6 7 {
		* beta
		matrix ANC4_`i'_post_be[`j',1] = ANC4_`i'_post_temp[1,`j']
		* standard error
		matrix ANC4_`i'_post_se[`j',1] = ANC4_`i'_post_temp[2,`j']
		* p value
		matrix ANC4_`i'_post_pv[`j',1] = ANC4_`i'_post_temp[4,`j']
		matrix ANC4_`i'_post_wpv[`j',1] = ANC4_`i'_post_temp_p[`j',1]
	}

*	cgmwildboot `i' treatment wrongDT cheating wrongTshort wrongTlong dum_grade, ///
*	cluster(school_no) bootcluster(school_no) null(0 . . . . . ) reps(999) seed(1)


	
}

foreach i in ptsel_overall_score {

	 regress `i' treatment pts_pre_miss pts_dum_miss, cluster(school_no)

	matrix ANC4_`i'_temp = r(table)
	matrix ANC4_`i'_r2 = e(r2)
	matrix ANC4_`i'_obs = e(N)

	  cgmwildboot_2 `i' treatment pts_pre_miss pts_dum_miss, cluster(school_no) bootcluster(school_no) null(0 . .) reps(999) seed(1)
	matrix ANC4_`i'_temp_p = e(Pvals)

	
	foreach s in be se pv rpv wpv {
		matrix ANC4_`i'_`s' = J(7,1,.)
	}

	foreach j in 1 2 3 4 5 6 7 {
		* beta
		matrix ANC4_`i'_be[`j',1] = ANC4_`i'_temp[1,`j']
		* standard error
		matrix ANC4_`i'_se[`j',1] = ANC4_`i'_temp[2,`j']
		* p value
		matrix ANC4_`i'_pv[`j',1] = ANC4_`i'_temp[4,`j']
		matrix ANC4_`i'_wpv[`j',1] = ANC4_`i'_temp_p[`j',1]
	}

*	cgmwildboot `i' treatment wrongDT cheating wrongTshort wrongTlong dum_grade, ///
*	cluster(school_no) bootcluster(school_no) null(0 . . . . . ) reps(999) seed(1)


	
}




foreach i in rosen cpcs {

	 regress `i'_el treatment `i'_pre_miss `i'_dum_miss, cluster(school_no)

	matrix ANC4_`i'_el_temp = r(table)
	matrix ANC4_`i'_el_r2 = e(r2)
	matrix ANC4_`i'_el_obs = e(N)

	  cgmwildboot_2 `i'_el treatment `i'_pre_miss `i'_dum_miss, cluster(school_no) bootcluster(school_no) null(0 . .) reps(999) seed(1)
	matrix ANC4_`i'_el_temp_p = e(Pvals)

	
	foreach s in be se pv rpv wpv {
		matrix ANC4_`i'_el_`s' = J(7,1,.)
	}

	foreach j in 1 2 3 4 5 6 7 {
		* beta
		matrix ANC4_`i'_el_be[`j',1] = ANC4_`i'_el_temp[1,`j']
		* standard error
		matrix ANC4_`i'_el_se[`j',1] = ANC4_`i'_el_temp[2,`j']
		* p value
		matrix ANC4_`i'_el_pv[`j',1] = ANC4_`i'_el_temp[4,`j']
		matrix ANC4_`i'_el_wpv[`j',1] = ANC4_`i'_el_temp_p[`j',1]
	}

*	cgmwildboot `i' treatment wrongDT cheating wrongTshort wrongTlong dum_grade, ///
*	cluster(school_no) bootcluster(school_no) null(0 . . . . . ) reps(999) seed(1)


	
}



foreach s in be se pv rpv r2 obs wpv {
	matrix ANC4_`s' = ANC4_DT_per_min_post_`s', ANC4_DT_score_post_`s', ///
	ANC4_DT_time_post_`s', ANC4_ptsel_overall_score_`s', ///
	ANC4_rosen_el_`s', ANC4_cpcs_el_`s'
}





restore





































*** ANCOVA  (table 2 panel B)

foreach i in DT_per_min DT_score DT_time {
replace `i'_pre = . if wrongDT == 1
gen `i'_pre_miss = `i'_pre
gen `i'_dum_miss = 0
replace `i'_dum_miss = 1 if `i'_pre == .
egen mean_`i'_pre = mean(`i'_pre)
replace `i'_pre_miss = mean_`i'_pre if `i'_pre == .
*replace `i'_pre_miss = 0 if `i'_pre == .
}




gen pts_pre_miss = ptsbl_overall_score
gen pts_dum_miss = 0
replace pts_dum_miss = 1 if ptsbl_overall_score == .
egen mean_pts_pre = mean(ptsbl_overall_score)
replace pts_pre_miss = mean_pts_pre if ptsbl_overall_score == .
*replace pts_pre_miss = 0 if ptsbl_overall_score == .





foreach i in rosen cpcs {
gen `i'_pre_miss = `i'_bl
gen `i'_dum_miss = 0
replace `i'_dum_miss = 1 if `i'_bl == .
egen mean_`i'_pre = mean(`i'_bl)
replace `i'_pre_miss = mean_`i'_pre if `i'_bl == .
*replace `i'_pre_miss = 0 if `i'_bl == .
}




foreach i in DT_per_min DT_score DT_time  {

	 regress `i'_post treatment `i'_pre_miss `i'_dum_miss, cluster(school_no)

	matrix ANC2_`i'_post_temp = r(table)
	matrix ANC2_`i'_post_r2 = e(r2)
	matrix ANC2_`i'_post_obs = e(N)

	  cgmwildboot_2 `i'_post treatment `i'_pre_miss `i'_dum_miss, cluster(school_no) bootcluster(school_no) null(0 . .) reps(999) seed(1)
	matrix ANC2_`i'_post_temp_p = e(Pvals)

	
	foreach s in be se pv rpv wpv {
		matrix ANC2_`i'_post_`s' = J(7,1,.)
	}

	foreach j in 1 2 3 4 5 6 7 {
		* beta
		matrix ANC2_`i'_post_be[`j',1] = ANC2_`i'_post_temp[1,`j']
		* standard error
		matrix ANC2_`i'_post_se[`j',1] = ANC2_`i'_post_temp[2,`j']
		* p value
		matrix ANC2_`i'_post_pv[`j',1] = ANC2_`i'_post_temp[4,`j']
		matrix ANC2_`i'_post_wpv[`j',1] = ANC2_`i'_post_temp_p[`j',1]
	}

*	cgmwildboot `i' treatment wrongDT cheating wrongTshort wrongTlong dum_grade, ///
*	cluster(school_no) bootcluster(school_no) null(0 . . . . . ) reps(999) seed(1)


	
}

foreach i in ptsel_overall_score {

	 regress `i' treatment pts_pre_miss pts_dum_miss, cluster(school_no)

	matrix ANC2_`i'_temp = r(table)
	matrix ANC2_`i'_r2 = e(r2)
	matrix ANC2_`i'_obs = e(N)

	  cgmwildboot_2 `i' treatment pts_pre_miss pts_dum_miss, cluster(school_no) bootcluster(school_no) null(0 . .) reps(999) seed(1)
	matrix ANC2_`i'_temp_p = e(Pvals)

	
	foreach s in be se pv rpv wpv {
		matrix ANC2_`i'_`s' = J(7,1,.)
	}

	foreach j in 1 2 3 4 5 6 7 {
		* beta
		matrix ANC2_`i'_be[`j',1] = ANC2_`i'_temp[1,`j']
		* standard error
		matrix ANC2_`i'_se[`j',1] = ANC2_`i'_temp[2,`j']
		* p value
		matrix ANC2_`i'_pv[`j',1] = ANC2_`i'_temp[4,`j']
		matrix ANC2_`i'_wpv[`j',1] = ANC2_`i'_temp_p[`j',1]
	}

*	cgmwildboot `i' treatment wrongDT cheating wrongTshort wrongTlong dum_grade, ///
*	cluster(school_no) bootcluster(school_no) null(0 . . . . . ) reps(999) seed(1)


	
}




foreach i in rosen cpcs {

	 regress `i'_el treatment `i'_pre_miss `i'_dum_miss, cluster(school_no)

	matrix ANC2_`i'_el_temp = r(table)
	matrix ANC2_`i'_el_r2 = e(r2)
	matrix ANC2_`i'_el_obs = e(N)

	  cgmwildboot_2 `i'_el treatment `i'_pre_miss `i'_dum_miss, cluster(school_no) bootcluster(school_no) null(0 . .) reps(999) seed(1)
	matrix ANC2_`i'_el_temp_p = e(Pvals)

	
	foreach s in be se pv rpv wpv {
		matrix ANC2_`i'_el_`s' = J(7,1,.)
	}

	foreach j in 1 2 3 4 5 6 7 {
		* beta
		matrix ANC2_`i'_el_be[`j',1] = ANC2_`i'_el_temp[1,`j']
		* standard error
		matrix ANC2_`i'_el_se[`j',1] = ANC2_`i'_el_temp[2,`j']
		* p value
		matrix ANC2_`i'_el_pv[`j',1] = ANC2_`i'_el_temp[4,`j']
		matrix ANC2_`i'_el_wpv[`j',1] = ANC2_`i'_el_temp_p[`j',1]
	}

*	cgmwildboot `i' treatment wrongDT cheating wrongTshort wrongTlong dum_grade, ///
*	cluster(school_no) bootcluster(school_no) null(0 . . . . . ) reps(999) seed(1)


	
}



foreach s in be se pv rpv r2 obs wpv {
	matrix ANC2_`s' = ANC2_DT_per_min_post_`s', ANC2_DT_score_post_`s', ///
	ANC2_DT_time_post_`s', ANC2_ptsel_overall_score_`s', ///
	ANC2_rosen_el_`s', ANC2_cpcs_el_`s'
}








** Ancova without wrong DT (table E1 panel B)

foreach i in DT_per_min DT_score DT_time  {

	 regress `i'_post treatment `i'_pre_miss `i'_dum_miss if `i'_pre != ., cluster(school_no)

	matrix ANC3_`i'_post_temp = r(table)
	matrix ANC3_`i'_post_r2 = e(r2)
	matrix ANC3_`i'_post_obs = e(N)

	  cgmwildboot_2 `i'_post treatment `i'_pre_miss `i'_dum_miss if `i'_pre != ., cluster(school_no) bootcluster(school_no) null(0 . .) reps(999) seed(1)
	matrix ANC3_`i'_post_temp_p = e(Pvals)

	
	foreach s in be se pv rpv wpv {
		matrix ANC3_`i'_post_`s' = J(7,1,.)
	}

	foreach j in 1 2 3 4 5 6 7 {
		* beta
		matrix ANC3_`i'_post_be[`j',1] = ANC3_`i'_post_temp[1,`j']
		* standard error
		matrix ANC3_`i'_post_se[`j',1] = ANC3_`i'_post_temp[2,`j']
		* p value
		matrix ANC3_`i'_post_pv[`j',1] = ANC3_`i'_post_temp[4,`j']
		matrix ANC3_`i'_post_wpv[`j',1] = ANC3_`i'_post_temp_p[`j',1]
	}

*	cgmwildboot `i' treatment wrongDT cheating wrongTshort wrongTlong dum_grade, ///
*	cluster(school_no) bootcluster(school_no) null(0 . . . . . ) reps(999) seed(1)


	
}

foreach i in ptsel_overall_score {

	 regress `i' treatment pts_pre_miss pts_dum_miss if ptsbl_overall_score != ., cluster(school_no)

	matrix ANC3_`i'_temp = r(table)
	matrix ANC3_`i'_r2 = e(r2)
	matrix ANC3_`i'_obs = e(N)

	  cgmwildboot_2 `i' treatment pts_pre_miss pts_dum_miss if ptsbl_overall_score != ., cluster(school_no) bootcluster(school_no) null(0 . .) reps(999) seed(1)
	matrix ANC3_`i'_temp_p = e(Pvals)

	
	foreach s in be se pv rpv wpv {
		matrix ANC3_`i'_`s' = J(7,1,.)
	}

	foreach j in 1 2 3 4 5 6 7 {
		* beta
		matrix ANC3_`i'_be[`j',1] = ANC3_`i'_temp[1,`j']
		* standard error
		matrix ANC3_`i'_se[`j',1] = ANC3_`i'_temp[2,`j']
		* p value
		matrix ANC3_`i'_pv[`j',1] = ANC3_`i'_temp[4,`j']
		matrix ANC3_`i'_wpv[`j',1] = ANC3_`i'_temp_p[`j',1]
	}

*	cgmwildboot `i' treatment wrongDT cheating wrongTshort wrongTlong dum_grade, ///
*	cluster(school_no) bootcluster(school_no) null(0 . . . . . ) reps(999) seed(1)


	
}




foreach i in rosen cpcs {

	 regress `i'_el treatment `i'_pre_miss `i'_dum_miss if `i'_bl != ., cluster(school_no)

	matrix ANC3_`i'_el_temp = r(table)
	matrix ANC3_`i'_el_r2 = e(r2)
	matrix ANC3_`i'_el_obs = e(N)

	  cgmwildboot_2 `i'_el treatment `i'_pre_miss `i'_dum_miss if `i'_bl != ., cluster(school_no) bootcluster(school_no) null(0 . .) reps(999) seed(1)
	matrix ANC3_`i'_el_temp_p = e(Pvals)

	
	foreach s in be se pv rpv wpv {
		matrix ANC3_`i'_el_`s' = J(7,1,.)
	}

	foreach j in 1 2 3 4 5 6 7 {
		* beta
		matrix ANC3_`i'_el_be[`j',1] = ANC3_`i'_el_temp[1,`j']
		* standard error
		matrix ANC3_`i'_el_se[`j',1] = ANC3_`i'_el_temp[2,`j']
		* p value
		matrix ANC3_`i'_el_pv[`j',1] = ANC3_`i'_el_temp[4,`j']
		matrix ANC3_`i'_el_wpv[`j',1] = ANC3_`i'_el_temp_p[`j',1]
	}

*	cgmwildboot `i' treatment wrongDT cheating wrongTshort wrongTlong dum_grade, ///
*	cluster(school_no) bootcluster(school_no) null(0 . . . . . ) reps(999) seed(1)


	
}



foreach s in be se pv rpv r2 obs wpv {
	matrix ANC3_`s' = ANC3_DT_per_min_post_`s', ANC3_DT_score_post_`s', ///
	ANC3_DT_time_post_`s', ANC3_ptsel_overall_score_`s', ///
	ANC3_rosen_el_`s', ANC3_cpcs_el_`s'
}








forvalues n = 1/4 {
forvalues item = 1/4 {
		forvalues scale = 1/6 {
		if ORI`n'_wpv[`item', `scale']<=0.01 {
			local star`n'_`item'`scale' %3s "***"
		}
		else if (ORI`n'_wpv[`item', `scale']>0.01) & (ORI`n'_wpv[`item', `scale']<=0.05) {
			local star`n'_`item'`scale' %2s "**"
		}
		else if (ORI`n'_wpv[`item', `scale']>0.05) & (ORI`n'_wpv[`item', `scale']<=0.10) {
			local star`n'_`item'`scale' %1s "*"
		}
		else {
			local star`n'_`item'`scale'  ""
		}
	} // forvalues `scale' loop

}  // forvalues `item' loop


} // forvalues `n' loop






forvalues n = 1/4 {
forvalues item = 1/4 {
		forvalues scale = 1/6 {
		if ORI`n'_pv[`item', `scale']<=0.01 {
			local nstar`n'_`item'`scale' %3s "***"
		}
		else if (ORI`n'_pv[`item', `scale']>0.01) & (ORI`n'_pv[`item', `scale']<=0.05) {
			local nstar`n'_`item'`scale' %2s "**"
		}
		else if (ORI`n'_pv[`item', `scale']>0.05) & (ORI`n'_pv[`item', `scale']<=0.10) {
			local nstar`n'_`item'`scale' %1s "*"
		}
		else {
			local nstar`n'_`item'`scale'  ""
		}
	} // forvalues `scale' loop

}  // forvalues `item' loop


} // forvalues `n' loop











forvalues n = 1/2 {
forvalues item = 1/4 {
		forvalues scale = 1/6 {
		if ALa0`n'_wpv[`item', `scale']<=0.01 {
			local starA`n'_`item'`scale' %3s "***"
		}
		else if (ALa0`n'_wpv[`item', `scale']>0.01) & (ALa0`n'_wpv[`item', `scale']<=0.05) {
			local starA`n'_`item'`scale' %2s "**"
		}
		else if (ALa0`n'_wpv[`item', `scale']>0.05) & (ALa0`n'_wpv[`item', `scale']<=0.10) {
			local starA`n'_`item'`scale' %1s "*"
		}
		else {
			local starA`n'_`item'`scale'  ""
		}
	} // forvalues `scale' loop

}  // forvalues `item' loop


} // forvalues `n' loop






forvalues n = 1/2 {
forvalues item = 1/4 {
		forvalues scale = 1/6 {
		if ALa0`n'_pv[`item', `scale']<=0.01 {
			local nstarA`n'_`item'`scale' %3s "***"
		}
		else if (ALa0`n'_pv[`item', `scale']>0.01) & (ALa0`n'_pv[`item', `scale']<=0.05) {
			local nstarA`n'_`item'`scale' %2s "**"
		}
		else if (ALa0`n'_pv[`item', `scale']>0.05) & (ALa0`n'_pv[`item', `scale']<=0.10) {
			local nstarA`n'_`item'`scale' %1s "*"
		}
		else {
			local nstarA`n'_`item'`scale'  ""
		}
	} // forvalues `scale' loop

}  // forvalues `item' loop


} // forvalues `n' loop




forvalues n = 4/5 {
forvalues item = 1/4 {
		forvalues scale = 1/6 {
		if ALa`n'_wpv[`item', `scale']<=0.01 {
			local starAl`n'_`item'`scale' %3s "***"
		}
		else if (ALa`n'_wpv[`item', `scale']>0.01) & (ALa`n'_wpv[`item', `scale']<=0.05) {
			local starAl`n'_`item'`scale' %2s "**"
		}
		else if (ALa`n'_wpv[`item', `scale']>0.05) & (ALa`n'_wpv[`item', `scale']<=0.10) {
			local starAl`n'_`item'`scale' %1s "*"
		}
		else {
			local starAl`n'_`item'`scale'  ""
		}
	} // forvalues `scale' loop

}  // forvalues `item' loop


} // forvalues `n' loop






forvalues n = 4/5 {
forvalues item = 1/4 {
		forvalues scale = 1/6 {
		if ALa`n'_pv[`item', `scale']<=0.01 {
			local nstarAl`n'_`item'`scale' %3s "***"
		}
		else if (ALa`n'_pv[`item', `scale']>0.01) & (ALa`n'_pv[`item', `scale']<=0.05) {
			local nstarAl`n'_`item'`scale' %2s "**"
		}
		else if (ALa`n'_pv[`item', `scale']>0.05) & (ALa`n'_pv[`item', `scale']<=0.10) {
			local nstarAl`n'_`item'`scale' %1s "*"
		}
		else {
			local nstarAl`n'_`item'`scale'  ""
		}
	} // forvalues `scale' loop

}  // forvalues `item' loop


} // forvalues `n' loop






forvalues n = 1/4 {
forvalues item = 1/4 {
		forvalues scale = 1/6 {
		if ANC`n'_wpv[`item', `scale']<=0.01 {
			local ancstar`n'_`item'`scale' %3s "***"
		}
		else if (ANC`n'_wpv[`item', `scale']>0.01) & (ANC`n'_wpv[`item', `scale']<=0.05) {
			local ancstar`n'_`item'`scale' %2s "**"
		}
		else if (ANC`n'_wpv[`item', `scale']>0.05) & (ANC`n'_wpv[`item', `scale']<=0.10) {
			local ancstar`n'_`item'`scale' %1s "*"
		}
		else {
			local ancstar`n'_`item'`scale'  ""
		}
	} // forvalues `scale' loop

}  // forvalues `item' loop


} // forvalues `n' loop





forvalues n = 1/4 {
forvalues item = 1/4 {
		forvalues scale = 1/6 {
		if ANC`n'_pv[`item', `scale']<=0.01 {
			local nancstar`n'_`item'`scale' %3s "***"
		}
		else if (ANC`n'_pv[`item', `scale']>0.01) & (ANC`n'_pv[`item', `scale']<=0.05) {
			local nancstar`n'_`item'`scale' %2s "**"
		}
		else if (ANC`n'_pv[`item', `scale']>0.05) & (ANC`n'_pv[`item', `scale']<=0.10) {
			local nancstar`n'_`item'`scale' %1s "*"
		}
		else {
			local nancstar`n'_`item'`scale'  ""
		}
	} // forvalues `scale' loop

}  // forvalues `item' loop


} // forvalues `n' loop















tempname hh
file open `hh' using "$pardir/tableE2.tex", write replace
file write `hh' "" _newline
file write `hh' "% Date: `c(current_date)'" _newline
file write `hh' "% Time: `c(current_time)'" _newline
file write `hh' "" _newline




file write `hh' "\begin{sidewaystable}[t!]\footnotesize" _newline
file write `hh' "  \centering" _newline
file write `hh' "  \caption{Impact of Kumon on Students' Learning Outcomes}" _newline
file write `hh' "\label{tab:DID_main}" _newline
file write `hh' "\scalebox{0.7}{" _newline
file write `hh' "\begin{threeparttable}" _newline
file write `hh' "\begin{tabular}{lcccccc}\toprule" _newline
file write `hh' "Dependent Variable & DT Score per min\textsuperscript{a} & DT Score & DT Time   & PTSII-C Score\textsuperscript{b} & RSES Index\textsuperscript{c}     & CPCS Index\textsuperscript{c} \\" _newline
file write `hh' " & (1) & (2) & (3) & (4) & (5) & (6)   \\\midrule\midrule" _newline
file write `hh' "                    &                  &          &           &               &         &          \\" _newline






file write `hh' "\multicolumn{7}{l}{\textbf{Panel A: Endline Estimates}}" _newline
file write `hh' "\\\midrule" _newline

file write `hh' "Treatment           &  " %04.3f (ALa02_be[1, 1]) `starA2_11' "  &  " %04.3f (ALa02_be[1, 2]) `starA2_12' "  &  " %04.3f (ALa02_be[1, 3]) `starA2_13' "  &  " %04.3f (ORI2_be[1, 4]) `starA2_14' "  &  " %04.3f (ORI2_be[1, 5]) `starA2_15' "  &  " %04.3f (ORI2_be[1, 6]) `starA2_26' "  \\" _newline
*file write `hh' "Treatment           &  " %04.3f (ALa02_be[1, 1]) `starA2_11' "  &  " %04.3f (ALa02_be[1, 2]) `starA2_12' "  &  " %04.3f (ALa02_be[1, 3]) `starA2_13' "  &  " %04.3f (ORI2_be[1, 4]) `star2_14' "  &  " %04.3f (ORI2_be[1, 5]) `star2_15' "  &  " %04.3f (ORI2_be[1, 6]) `star1_26' "  \\" _newline
file write `hh' "                    & (" %04.3f (ALa02_se[1, 1]) ") & (" %04.3f (ALa02_se[1, 2]) ") & (" %04.3f (ALa02_se[1, 3]) ") & (" %04.3f (ORI2_se[1, 4]) ") & (" %04.3f (ORI2_se[1, 5]) ") & (" %04.3f (ORI2_se[1, 6]) ") \\" _newline
file write `hh' "Constant            &  " %04.3f (ALa02_be[2, 1]) `nstarA2_21' "  &  " %04.3f (ALa02_be[2, 2]) `nstarA2_22' "  &  " %04.3f (ALa02_be[2, 3]) `nstarA2_23' "  &  " %04.3f (ORI2_be[2, 4]) `nstarA2_24' "  &  " %04.3f (ORI2_be[2, 5]) `nstarA2_25' "  &  " %04.3f (ORI2_be[2, 6]) `nstarA2_26' "  \\" _newline
file write `hh' "                    & (" %04.3f (ALa02_se[2, 1]) ") & (" %04.3f (ALa02_se[2, 2]) ") & (" %04.3f (ALa02_se[2, 3]) ") & (" %04.3f (ORI2_se[2, 4]) ") & (" %04.3f (ORI2_se[2, 5]) ") & (" %04.3f (ORI2_se[2, 6]) ") \\" _newline
file write `hh' "                    &                                 &                                 &                                 &                                 &                                 &                         \\\midrule" _newline
file write `hh' "Num of Obs.         &  " (ALa02_obs[1, 1]) " &  " (ALa02_obs[1, 2]) " &  " (ALa02_obs[1, 3]) " &  " (ORI2_obs[1, 4]) " &  " (ORI2_obs[1, 5]) " &  " (ORI2_obs[1, 6]) " \\" _newline
file write `hh' "R-squared           &  " %04.3f (ALa02_r2[1, 1]) "  &  " %04.3f (ALa02_r2[1, 2]) "  &  " %04.3f (ALa02_r2[1, 3]) "  &  " %04.3f (ORI2_r2[1, 4]) "  &  " %04.3f (ORI2_r2[1, 5]) "  &  " %04.3f (ORI2_r2[1, 6]) "  \\" _newline
file write `hh' "                    &                  &          &           &               &         &          \\" _newline
file write `hh' "p-value (individual hypothesis testing) &  " %04.3f (ALa02_pv[1, 1]) "  &  " %04.3f (ALa02_pv[1, 2]) "  &  " %04.3f (ALa02_pv[1, 3]) "  &  " %04.3f (ALa02_pv[1, 4]) "  &  " %04.3f (ALa02_pv[1, 5]) "  &  " %04.3f (ALa02_pv[1, 6]) "  \\" _newline
file write `hh' "p-value (individual hypothesis testing, wild bootstrap) &  " %04.3f (ALa02_wpv[1, 1]) "  &  " %04.3f (ALa02_wpv[1, 2]) "  &  " %04.3f (ALa02_wpv[1, 3]) "  &  " %04.3f (ALa02_wpv[1, 4]) "  &  " %04.3f (ALa02_wpv[1, 5]) "  &  " %04.3f (ALa02_wpv[1, 6]) "  \\" _newline
file write `hh' "p-value (Romano-Wolf stepdown p-value) &  " %04.3f (ALa02_rpv[1, 1]) "  &  " %04.3f (ALa02_rpv[1, 2]) "  &  " %04.3f (ALa02_rpv[1, 3]) "  &  " %04.3f (ALa02_rpv[1, 4]) "  &  " %04.3f (ALa02_rpv[1, 5]) "  &  " %04.3f (ALa02_rpv[1, 6]) "  \\" _newline
file write `hh' "                    &                  &          &           &               &         &          \\\bottomrule" _newline

file write `hh' "                    &                  &          &           &               &         &          \\" _newline



file write `hh' "                    &                  &          &           &               &         &          \\" _newline



file write `hh' "\multicolumn{7}{l}{\textbf{Panel B: ANCOVA Estimates}}" _newline
file write `hh' "\\\midrule" _newline

file write `hh' "Treatment           &  " %04.3f (ANC3_be[1, 1]) `ancstar3_11' "  &  " %04.3f (ANC3_be[1, 2]) `ancstar3_12' "  &  " %04.3f (ANC3_be[1, 3]) `ancstar3_13' "  &  " %04.3f (ANC3_be[1, 4]) `ancstar3_14' "  &  " %04.3f (ANC3_be[1, 5]) `ancstar3_15' "  &  " %04.3f (ANC3_be[1, 6]) `ancstar3_16' "  \\" _newline
*file write `hh' "Treatment           &  " %04.3f (ALa02_be[1, 1]) `starA2_11' "  &  " %04.3f (ALa02_be[1, 2]) `starA2_12' "  &  " %04.3f (ALa02_be[1, 3]) `starA2_13' "  &  " %04.3f (ANC3_be[1, 4]) `star2_14' "  &  " %04.3f (ANC3_be[1, 5]) `star2_15' "  &  " %04.3f (ANC3_be[1, 6]) `star3_26' "  \\" _newline
file write `hh' "                    & (" %04.3f (ANC3_se[1, 1]) ") & (" %04.3f (ANC3_se[1, 2]) ") & (" %04.3f (ANC3_se[1, 3]) ") & (" %04.3f (ANC3_se[1, 4]) ") & (" %04.3f (ANC3_se[1, 5]) ") & (" %04.3f (ANC3_se[1, 6]) ") \\" _newline
file write `hh' "Baseline Outcome    &  " %04.3f (ANC3_be[2, 1]) `ancstar3_21' "  &  " %04.3f (ANC3_be[2, 2]) `ancstar3_22' "  &  " %04.3f (ANC3_be[2, 3]) `ancstar3_23' "  &  " %04.3f (ANC3_be[2, 4]) `ancstar3_24' "  &  " %04.3f (ANC3_be[2, 5]) `ancstar3_25' "  &  " %04.3f (ANC3_be[2, 6]) `ancstar3_26' "  \\" _newline
file write `hh' "                    & (" %04.3f (ANC3_se[2, 1]) ") & (" %04.3f (ANC3_se[2, 2]) ") & (" %04.3f (ANC3_se[2, 3]) ") & (" %04.3f (ANC3_se[2, 4]) ") & (" %04.3f (ANC3_se[2, 5]) ") & (" %04.3f (ANC3_se[2, 6]) ") \\" _newline
file write `hh' "Constant            &  " %04.3f (ANC3_be[4, 1]) `nancstar3_41' "  &  " %04.3f (ANC3_be[4, 2]) `nancstar3_42' "  &  " %04.3f (ANC3_be[4, 3]) `nancstar3_43' "  &  " %04.3f (ANC3_be[4, 4]) `nancstar3_44' "  &  " %04.3f (ANC3_be[4, 5]) `nancstar3_45' "  &  " %04.3f (ANC3_be[4, 6]) `nancstar3_46' "  \\" _newline
file write `hh' "                    & (" %04.3f (ANC3_se[4, 1]) ") & (" %04.3f (ANC3_se[4, 2]) ") & (" %04.3f (ANC3_se[4, 3]) ") & (" %04.3f (ANC3_se[4, 4]) ") & (" %04.3f (ANC3_se[4, 5]) ") & (" %04.3f (ANC3_se[4, 6]) ") \\" _newline
file write `hh' "                    &                                 &                                 &                                 &                                 &                                 &                         \\\midrule" _newline
file write `hh' "Num of Obs.         &  " (ANC3_obs[1, 1]) " &  " (ANC3_obs[1, 2]) " &  " (ANC3_obs[1, 3]) " &  " (ANC3_obs[1, 4]) " &  " (ANC3_obs[1, 5]) " &  " (ANC3_obs[1, 6]) " \\" _newline
file write `hh' "R-squared           &  " %04.3f (ANC3_r2[1, 1]) "  &  " %04.3f (ANC3_r2[1, 2]) "  &  " %04.3f (ANC3_r2[1, 3]) "  &  " %04.3f (ANC3_r2[1, 4]) "  &  " %04.3f (ANC3_r2[1, 5]) "  &  " %04.3f (ANC3_r2[1, 6]) "  \\" _newline
file write `hh' "                    &                  &          &           &               &         &          \\" _newline
file write `hh' "p-value (individual hypothesis testing) &  " %04.3f (ANC3_pv[1, 1]) "  &  " %04.3f (ANC3_pv[1, 2]) "  &  " %04.3f (ANC3_pv[1, 3]) "  &  " %04.3f (ANC3_pv[1, 4]) "  &  " %04.3f (ANC3_pv[1, 5]) "  &  " %04.3f (ANC3_pv[1, 6]) "  \\" _newline
file write `hh' "p-value (individual hypothesis testing, wild bootstrap) &  " %04.3f (ANC3_wpv[1, 1]) "  &  " %04.3f (ANC3_wpv[1, 2]) "  &  " %04.3f (ANC3_wpv[1, 3]) "  &  " %04.3f (ANC3_wpv[1, 4]) "  &  " %04.3f (ANC3_wpv[1, 5]) "  &  " %04.3f (ANC3_wpv[1, 6]) "  \\" _newline
file write `hh' "                    &                  &          &           &               &         &          \\\bottomrule" _newline





file write `hh' "\multicolumn{7}{l}{\textbf{Panel C: First Difference Estimates}}" _newline
file write `hh' "\\\midrule" _newline
*file write `hh' "Treatment           &  " %04.3f (ALa1_be[1, 1]) `starA1_11' "  &  " %04.3f (ALa1_be[1, 2]) `starA1_12' "  &  " %04.3f (ALa1_be[1, 3]) `starA1_13' "  &  " %04.3f (ORI1_be[1, 4]) `star1_14' "  &  " %04.3f (ORI1_be[1, 5]) `star1_15' "  &  " %04.3f (ORI1_be[1, 6]) `star1_16' "  \\" _newline
file write `hh' "Treatment           &  " %04.3f (ALa01_be[1, 1]) `starA1_11' "  &  " %04.3f (ALa01_be[1, 2]) `starA1_12' "  &  " %04.3f (ALa01_be[1, 3]) `starA1_13' "  &  " %04.3f (ORI1_be[1, 4]) `star1_14' "  &  " %04.3f (ORI1_be[1, 5]) `star1_15' "  &  " %04.3f (ORI1_be[1, 6]) `star1_16' "  \\" _newline
file write `hh' "                    & (" %04.3f (ALa01_se[1, 1]) ") & (" %04.3f (ALa01_se[1, 2]) ") & (" %04.3f (ALa01_se[1, 3]) ") & (" %04.3f (ORI1_se[1, 4]) ") & (" %04.3f (ORI1_se[1, 5]) ") & (" %04.3f (ORI1_se[1, 6]) ") \\" _newline
file write `hh' "Constant            &  " %04.3f (ALa01_be[2, 1]) `nstarA1_21' "  &  " %04.3f (ALa01_be[2, 2]) `nstarA1_22' "  &  " %04.3f (ALa01_be[2, 3]) `nstarA1_23' "  &  " %04.3f (ORI1_be[2, 4]) `nstar1_24' "  &  " %04.3f (ORI1_be[2, 5]) `nstar1_25' "  &  " %04.3f (ORI1_be[2, 6]) `nstar1_26' "  \\" _newline
file write `hh' "                    & (" %04.3f (ALa01_se[2, 1]) ") & (" %04.3f (ALa01_se[2, 2]) ") & (" %04.3f (ALa01_se[2, 3]) ") & (" %04.3f (ORI1_se[2, 4]) ") & (" %04.3f (ORI1_se[2, 5]) ") & (" %04.3f (ORI1_se[2, 6]) ") \\" _newline
file write `hh' "                    &                                 &                                 &                                 &                                 &                                 &                         \\\midrule" _newline
file write `hh' "Num of Obs.         &  " (ALa01_obs[1, 1]) " &  " (ALa01_obs[1, 2]) " &  " (ALa01_obs[1, 3]) " &  " (ORI1_obs[1, 4]) " &  " (ORI1_obs[1, 5]) " &  " (ORI1_obs[1, 6]) " \\" _newline
file write `hh' "R-squared           &  " %04.3f (ALa01_r2[1, 1]) "  &  " %04.3f (ALa01_r2[1, 2]) "  &  " %04.3f (ALa01_r2[1, 3]) "  &  " %04.3f (ORI1_r2[1, 4]) "  &  " %04.3f (ORI1_r2[1, 5]) "  &  " %04.3f (ORI1_r2[1, 6]) "  \\" _newline
file write `hh' "                    &                  &          &           &               &         &          \\" _newline
file write `hh' "p-value (individual hypothesis testing) &  " %04.3f (ALa01_pv[1, 1]) "  &  " %04.3f (ALa01_pv[1, 2]) "  &  " %04.3f (ALa01_pv[1, 3]) "  &  " %04.3f (ALa01_pv[1, 4]) "  &  " %04.3f (ALa01_pv[1, 5]) "  &  " %04.3f (ALa01_pv[1, 6]) "  \\" _newline
file write `hh' "p-value (individual hypothesis testing, wild bootstrap) &  " %04.3f (ALa01_wpv[1, 1]) "  &  " %04.3f (ALa01_wpv[1, 2]) "  &  " %04.3f (ALa01_wpv[1, 3]) "  &  " %04.3f (ALa01_wpv[1, 4]) "  &  " %04.3f (ALa01_wpv[1, 5]) "  &  " %04.3f (ALa01_wpv[1, 6]) "  \\" _newline
file write `hh' "p-value (Romano-Wolf stepdown p-value) &  " %04.3f (ALa01_rpv[1, 1]) "  &  " %04.3f (ALa01_rpv[1, 2]) "  &  " %04.3f (ALa01_rpv[1, 3]) "  &  " %04.3f (ALa01_rpv[1, 4]) "  &  " %04.3f (ALa01_rpv[1, 5]) "  &  " %04.3f (ALa01_rpv[1, 6]) "  \\" _newline
file write `hh' "                    &                  &          &           &               &         &          \\\midrule" _newline




file write `hh' "\end{tabular}" _newline
file write `hh' "\end{threeparttable}" _newline
file write `hh' "}" _newline
file write `hh' "\label{tab:addlabel}%" _newline
file write `hh' "\end{sidewaystable}" _newline

file write `hh' "" _newline
file write `hh' "" _newline
file write `hh' "" _newline
file write `hh' "" _newline

file close `hh'












tempname hh
file open `hh' using "$pardir/table2.tex", write replace
file write `hh' "" _newline
file write `hh' "% Date: `c(current_date)'" _newline
file write `hh' "% Time: `c(current_time)'" _newline
file write `hh' "" _newline




file write `hh' "\begin{sidewaystable}[t!]\footnotesize" _newline
file write `hh' "  \centering" _newline
file write `hh' "  \caption{Impact of Kumon on Students' Learning Outcomes}" _newline
file write `hh' "\label{tab:DID_main}" _newline
file write `hh' "\scalebox{0.7}{" _newline
file write `hh' "\begin{threeparttable}" _newline
file write `hh' "\begin{tabular}{lcccccc}\toprule" _newline
file write `hh' "Dependent Variable & DT Score per min\textsuperscript{a} & DT Score & DT Time   & PTSII-C Score\textsuperscript{b} & RSES Index\textsuperscript{c}     & CPCS Index\textsuperscript{c} \\" _newline
file write `hh' " & (1) & (2) & (3) & (4) & (5) & (6)   \\\midrule\midrule" _newline
file write `hh' "                    &                  &          &           &               &         &          \\" _newline






file write `hh' "\multicolumn{7}{l}{\textbf{Panel A: Endline Estimates}}" _newline
file write `hh' "\\\midrule" _newline

file write `hh' "Treatment           &  " %04.3f (ALa4_be[1, 1]) `starAl4_11' "  &  " %04.3f (ALa4_be[1, 2]) `starAl4_12' "  &  " %04.3f (ALa4_be[1, 3]) `starAl4_13' "  &  " %04.3f (ALa4_be[1, 4]) `starAl4_14' "  &  " %04.3f (ALa4_be[1, 5]) `starAl4_15' "  &  " %04.3f (ALa4_be[1, 6]) `starAl4_16' "  \\" _newline
*file write `hh' "Treatment           &  " %04.3f (ALa4_be[1, 1]) `starA2_11' "  &  " %04.3f (ALa4_be[1, 2]) `starA2_12' "  &  " %04.3f (ALa4_be[1, 3]) `starA2_13' "  &  " %04.3f (ALa4_be[1, 4]) `star2_14' "  &  " %04.3f (ALa4_be[1, 5]) `star2_15' "  &  " %04.3f (ALa4_be[1, 6]) `star1_26' "  \\" _newline
file write `hh' "                    & (" %04.3f (ALa4_se[1, 1]) ") & (" %04.3f (ALa4_se[1, 2]) ") & (" %04.3f (ALa4_se[1, 3]) ") & (" %04.3f (ALa4_se[1, 4]) ") & (" %04.3f (ALa4_se[1, 5]) ") & (" %04.3f (ALa4_se[1, 6]) ") \\" _newline
file write `hh' "Constant            &  " %04.3f (ALa4_be[2, 1]) `nstarAl4_21' "  &  " %04.3f (ALa4_be[2, 2]) `nstarAl4_22' "  &  " %04.3f (ALa4_be[2, 3]) `nstarAl4_23' "  &  " %04.3f (ALa4_be[2, 4]) `nstarAl4_24' "  &  " %04.3f (ALa4_be[2, 5]) `nstarAl4_25' "  &  " %04.3f (ALa4_be[2, 6]) `nstarAl4_26' "  \\" _newline
file write `hh' "                    & (" %04.3f (ALa4_se[2, 1]) ") & (" %04.3f (ALa4_se[2, 2]) ") & (" %04.3f (ALa4_se[2, 3]) ") & (" %04.3f (ALa4_se[2, 4]) ") & (" %04.3f (ALa4_se[2, 5]) ") & (" %04.3f (ALa4_se[2, 6]) ") \\" _newline
file write `hh' "                    &                                 &                                 &                                 &                                 &                                 &                         \\\midrule" _newline
file write `hh' "Num of Obs.         &  " (ALa4_obs[1, 1]) " &  " (ALa4_obs[1, 2]) " &  " (ALa4_obs[1, 3]) " &  " (ALa4_obs[1, 4]) " &  " (ALa4_obs[1, 5]) " &  " (ALa4_obs[1, 6]) " \\" _newline
file write `hh' "R-squared           &  " %04.3f (ALa4_r2[1, 1]) "  &  " %04.3f (ALa4_r2[1, 2]) "  &  " %04.3f (ALa4_r2[1, 3]) "  &  " %04.3f (ALa4_r2[1, 4]) "  &  " %04.3f (ALa4_r2[1, 5]) "  &  " %04.3f (ALa4_r2[1, 6]) "  \\" _newline
file write `hh' "                    &                  &          &           &               &         &          \\" _newline
file write `hh' "p-value (individual hypothesis testing) &  " %04.3f (ALa4_pv[1, 1]) "  &  " %04.3f (ALa4_pv[1, 2]) "  &  " %04.3f (ALa4_pv[1, 3]) "  &  " %04.3f (ALa4_pv[1, 4]) "  &  " %04.3f (ALa4_pv[1, 5]) "  &  " %04.3f (ALa4_pv[1, 6]) "  \\" _newline
file write `hh' "p-value (individual hypothesis testing, wild bootstrap) &  " %04.3f (ALa4_wpv[1, 1]) "  &  " %04.3f (ALa4_wpv[1, 2]) "  &  " %04.3f (ALa4_wpv[1, 3]) "  &  " %04.3f (ALa4_wpv[1, 4]) "  &  " %04.3f (ALa4_wpv[1, 5]) "  &  " %04.3f (ALa4_wpv[1, 6]) "  \\" _newline
file write `hh' "                    &                  &          &           &               &         &          \\\bottomrule" _newline

file write `hh' "                    &                  &          &           &               &         &          \\" _newline






file write `hh' "\multicolumn{7}{l}{\textbf{Panel B: ANCOVA Estimates}}" _newline
file write `hh' "\\\midrule" _newline

file write `hh' "Treatment           &  " %04.3f (ANC2_be[1, 1]) `ancstar2_11' "  &  " %04.3f (ANC2_be[1, 2]) `ancstar2_12' "  &  " %04.3f (ANC2_be[1, 3]) `ancstar2_13' "  &  " %04.3f (ANC2_be[1, 4]) `ancstar2_14' "  &  " %04.3f (ANC2_be[1, 5]) `ancstar2_15' "  &  " %04.3f (ANC2_be[1, 6]) `ancstar2_16' "  \\" _newline
*file write `hh' "Treatment           &  " %04.3f (ALa02_be[1, 1]) `starA2_11' "  &  " %04.3f (ALa02_be[1, 2]) `starA2_12' "  &  " %04.3f (ALa02_be[1, 3]) `starA2_13' "  &  " %04.3f (ANC2_be[1, 4]) `star2_14' "  &  " %04.3f (ANC2_be[1, 5]) `star2_15' "  &  " %04.3f (ANC2_be[1, 6]) `star2_26' "  \\" _newline
file write `hh' "                    & (" %04.3f (ANC2_se[1, 1]) ") & (" %04.3f (ANC2_se[1, 2]) ") & (" %04.3f (ANC2_se[1, 3]) ") & (" %04.3f (ANC2_se[1, 4]) ") & (" %04.3f (ANC2_se[1, 5]) ") & (" %04.3f (ANC2_se[1, 6]) ") \\" _newline
file write `hh' "Baseline Outcome    &  " %04.3f (ANC2_be[2, 1]) `ancstar2_21' "  &  " %04.3f (ANC2_be[2, 2]) `ancstar2_22' "  &  " %04.3f (ANC2_be[2, 3]) `ancstar2_23' "  &  " %04.3f (ANC2_be[2, 4]) `ancstar2_24' "  &  " %04.3f (ANC2_be[2, 5]) `ancstar2_25' "  &  " %04.3f (ANC2_be[2, 6]) `ancstar2_26' "  \\" _newline
file write `hh' "                    & (" %04.3f (ANC2_se[2, 1]) ") & (" %04.3f (ANC2_se[2, 2]) ") & (" %04.3f (ANC2_se[2, 3]) ") & (" %04.3f (ANC2_se[2, 4]) ") & (" %04.3f (ANC2_se[2, 5]) ") & (" %04.3f (ANC2_se[2, 6]) ") \\" _newline
file write `hh' "Constant            &  " %04.3f (ANC2_be[4, 1]) `nancstar2_41' "  &  " %04.3f (ANC2_be[4, 2]) `nancstar2_42' "  &  " %04.3f (ANC2_be[4, 3]) `nancstar2_43' "  &  " %04.3f (ANC2_be[4, 4]) `nancstar2_44' "  &  " %04.3f (ANC2_be[4, 5]) `nancstar2_45' "  &  " %04.3f (ANC2_be[4, 6]) `nancstar2_46' "  \\" _newline
file write `hh' "                    & (" %04.3f (ANC2_se[4, 1]) ") & (" %04.3f (ANC2_se[4, 2]) ") & (" %04.3f (ANC2_se[4, 3]) ") & (" %04.3f (ANC2_se[4, 4]) ") & (" %04.3f (ANC2_se[4, 5]) ") & (" %04.3f (ANC2_se[4, 6]) ") \\" _newline
file write `hh' "                    &                                 &                                 &                                 &                                 &                                 &                         \\\midrule" _newline
file write `hh' "Num of Obs.         &  " (ANC2_obs[1, 1]) " &  " (ANC2_obs[1, 2]) " &  " (ANC2_obs[1, 3]) " &  " (ANC2_obs[1, 4]) " &  " (ANC2_obs[1, 5]) " &  " (ANC2_obs[1, 6]) " \\" _newline
file write `hh' "R-squared           &  " %04.3f (ANC2_r2[1, 1]) "  &  " %04.3f (ANC2_r2[1, 2]) "  &  " %04.3f (ANC2_r2[1, 3]) "  &  " %04.3f (ANC2_r2[1, 4]) "  &  " %04.3f (ANC2_r2[1, 5]) "  &  " %04.3f (ANC2_r2[1, 6]) "  \\" _newline
file write `hh' "                    &                  &          &           &               &         &          \\" _newline
file write `hh' "p-value (individual hypothesis testing) &  " %04.3f (ANC2_pv[1, 1]) "  &  " %04.3f (ANC2_pv[1, 2]) "  &  " %04.3f (ANC2_pv[1, 3]) "  &  " %04.3f (ANC2_pv[1, 4]) "  &  " %04.3f (ANC2_pv[1, 5]) "  &  " %04.3f (ANC2_pv[1, 6]) "  \\" _newline
file write `hh' "p-value (individual hypothesis testing, wild bootstrap) &  " %04.3f (ANC2_wpv[1, 1]) "  &  " %04.3f (ANC2_wpv[1, 2]) "  &  " %04.3f (ANC2_wpv[1, 3]) "  &  " %04.3f (ANC2_wpv[1, 4]) "  &  " %04.3f (ANC2_wpv[1, 5]) "  &  " %04.3f (ANC2_wpv[1, 6]) "  \\" _newline
file write `hh' "                    &                  &          &           &               &         &          \\\bottomrule" _newline






file write `hh' "\end{tabular}" _newline
file write `hh' "\end{threeparttable}" _newline
file write `hh' "}" _newline
file write `hh' "\label{tab:addlabel}%" _newline
file write `hh' "\end{sidewaystable}" _newline

file write `hh' "" _newline
file write `hh' "" _newline
file write `hh' "" _newline
file write `hh' "" _newline

file close `hh'











tempname hh
file open `hh' using "$pardir/tableE1.tex", write replace
file write `hh' "" _newline
file write `hh' "% Date: `c(current_date)'" _newline
file write `hh' "% Time: `c(current_time)'" _newline
file write `hh' "" _newline




file write `hh' "\begin{sidewaystable}[t!]\footnotesize" _newline
file write `hh' "  \centering" _newline
file write `hh' "  \caption{Impact of Kumon on Students' Learning Outcomes}" _newline
file write `hh' "\label{tab:DID_main}" _newline
file write `hh' "\scalebox{0.7}{" _newline
file write `hh' "\begin{threeparttable}" _newline
file write `hh' "\begin{tabular}{lcccccc}\toprule" _newline
file write `hh' "Dependent Variable & DT Score per min\textsuperscript{a} & DT Score & DT Time   & PTSII-C Score\textsuperscript{b} & RSES Index\textsuperscript{c}     & CPCS Index\textsuperscript{c} \\" _newline
file write `hh' " & (1) & (2) & (3) & (4) & (5) & (6)   \\\midrule\midrule" _newline
file write `hh' "                    &                  &          &           &               &         &          \\" _newline






file write `hh' "\multicolumn{7}{l}{\textbf{Panel A: Endline Estimates}}" _newline
file write `hh' "\\\midrule" _newline

file write `hh' "Treatment           &  " %04.3f (ALa5_be[1, 1]) `starAl5_11' "  &  " %04.3f (ALa5_be[1, 2]) `starAl5_12' "  &  " %04.3f (ALa5_be[1, 3]) `starAl5_13' "  &  " %04.3f (ALa5_be[1, 4]) `starAl5_14' "  &  " %04.3f (ALa5_be[1, 5]) `starAl5_15' "  &  " %04.3f (ALa5_be[1, 6]) `starAl5_16' "  \\" _newline
*file write `hh' "Treatment           &  " %04.3f (ALa5_be[1, 1]) `starA2_11' "  &  " %04.3f (ALa5_be[1, 2]) `starA2_12' "  &  " %04.3f (ALa5_be[1, 3]) `starA2_13' "  &  " %04.3f (ALa5_be[1, 4]) `star2_14' "  &  " %04.3f (ALa5_be[1, 5]) `star2_15' "  &  " %04.3f (ALa5_be[1, 6]) `star1_26' "  \\" _newline
file write `hh' "                    & (" %04.3f (ALa5_se[1, 1]) ") & (" %04.3f (ALa5_se[1, 2]) ") & (" %04.3f (ALa5_se[1, 3]) ") & (" %04.3f (ALa5_se[1, 4]) ") & (" %04.3f (ALa5_se[1, 5]) ") & (" %04.3f (ALa5_se[1, 6]) ") \\" _newline
file write `hh' "Constant            &  " %04.3f (ALa5_be[2, 1]) `nstarAl5_21' "  &  " %04.3f (ALa5_be[2, 2]) `nstarAl5_22' "  &  " %04.3f (ALa5_be[2, 3]) `nstarAl5_23' "  &  " %04.3f (ALa5_be[2, 4]) `nstarAl5_24' "  &  " %04.3f (ALa5_be[2, 5]) `nstarAl5_25' "  &  " %04.3f (ALa5_be[2, 6]) `nstarAl5_26' "  \\" _newline
file write `hh' "                    & (" %04.3f (ALa5_se[2, 1]) ") & (" %04.3f (ALa5_se[2, 2]) ") & (" %04.3f (ALa5_se[2, 3]) ") & (" %04.3f (ALa5_se[2, 4]) ") & (" %04.3f (ALa5_se[2, 5]) ") & (" %04.3f (ALa5_se[2, 6]) ") \\" _newline
file write `hh' "                    &                                 &                                 &                                 &                                 &                                 &                         \\\midrule" _newline
file write `hh' "Num of Obs.         &  " (ALa5_obs[1, 1]) " &  " (ALa5_obs[1, 2]) " &  " (ALa5_obs[1, 3]) " &  " (ALa5_obs[1, 4]) " &  " (ALa5_obs[1, 5]) " &  " (ALa5_obs[1, 6]) " \\" _newline
file write `hh' "R-squared           &  " %04.3f (ALa5_r2[1, 1]) "  &  " %04.3f (ALa5_r2[1, 2]) "  &  " %04.3f (ALa5_r2[1, 3]) "  &  " %04.3f (ALa5_r2[1, 4]) "  &  " %04.3f (ALa5_r2[1, 5]) "  &  " %04.3f (ALa5_r2[1, 6]) "  \\" _newline
file write `hh' "                    &                  &          &           &               &         &          \\" _newline
file write `hh' "p-value (individual hypothesis testing) &  " %04.3f (ALa5_pv[1, 1]) "  &  " %04.3f (ALa5_pv[1, 2]) "  &  " %04.3f (ALa5_pv[1, 3]) "  &  " %04.3f (ALa5_pv[1, 4]) "  &  " %04.3f (ALa5_pv[1, 5]) "  &  " %04.3f (ALa5_pv[1, 6]) "  \\" _newline
file write `hh' "p-value (individual hypothesis testing, wild bootstrap) &  " %04.3f (ALa5_wpv[1, 1]) "  &  " %04.3f (ALa5_wpv[1, 2]) "  &  " %04.3f (ALa5_wpv[1, 3]) "  &  " %04.3f (ALa5_wpv[1, 4]) "  &  " %04.3f (ALa5_wpv[1, 5]) "  &  " %04.3f (ALa5_wpv[1, 6]) "  \\" _newline
file write `hh' "                    &                  &          &           &               &         &          \\\bottomrule" _newline

file write `hh' "                    &                  &          &           &               &         &          \\" _newline






file write `hh' "\multicolumn{7}{l}{\textbf{Panel B: ANCOVA Estimates}}" _newline
file write `hh' "\\\midrule" _newline

file write `hh' "Treatment           &  " %04.3f (ANC4_be[1, 1]) `ancstar4_11' "  &  " %04.3f (ANC4_be[1, 2]) `ancstar4_12' "  &  " %04.3f (ANC4_be[1, 3]) `ancstar4_13' "  &  " %04.3f (ANC2_be[1, 4]) `ancstar2_12' "  &  " %04.3f (ANC2_be[1, 5]) `ancstar2_15' "  &  " %04.3f (ANC2_be[1, 6]) `ancstar2_16' "  \\" _newline
*file write `hh' "Treatment           &  " %04.3f (ALa02_be[1, 1]) `starA2_11' "  &  " %04.3f (ALa02_be[1, 2]) `starA2_12' "  &  " %04.3f (ALa02_be[1, 3]) `starA2_13' "  &  " %04.3f (ANC4_be[1, 4]) `star2_14' "  &  " %04.3f (ANC4_be[1, 5]) `star2_15' "  &  " %04.3f (ANC4_be[1, 6]) `star2_26' "  \\" _newline
file write `hh' "                    & (" %04.3f (ANC4_se[1, 1]) ") & (" %04.3f (ANC4_se[1, 2]) ") & (" %04.3f (ANC4_se[1, 3]) ") & (" %04.3f (ANC2_se[1, 4]) ") & (" %04.3f (ANC2_se[1, 5]) ") & (" %04.3f (ANC2_se[1, 6]) ") \\" _newline
file write `hh' "Baseline Outcome    &  " %04.3f (ANC4_be[2, 1]) `ancstar4_21' "  &  " %04.3f (ANC4_be[2, 2]) `ancstar4_22' "  &  " %04.3f (ANC4_be[2, 3]) `ancstar4_23' "  &  " %04.3f (ANC2_be[2, 4]) `ancstar2_24' "  &  " %04.3f (ANC2_be[2, 5]) `ancstar2_25' "  &  " %04.3f (ANC2_be[2, 6]) `ancstar2_26' "  \\" _newline
file write `hh' "                    & (" %04.3f (ANC4_se[2, 1]) ") & (" %04.3f (ANC4_se[2, 2]) ") & (" %04.3f (ANC4_se[2, 3]) ") & (" %04.3f (ANC2_se[2, 4]) ") & (" %04.3f (ANC2_se[2, 5]) ") & (" %04.3f (ANC2_se[2, 6]) ") \\" _newline
file write `hh' "Constant            &  " %04.3f (ANC4_be[4, 1]) `nancstar4_41' "  &  " %04.3f (ANC4_be[4, 2]) `nancstar4_42' "  &  " %04.3f (ANC4_be[4, 3]) `nancstar4_43' "  &  " %04.3f (ANC2_be[4, 4]) `nancstar2_44' "  &  " %04.3f (ANC2_be[4, 5]) `nancstar2_45' "  &  " %04.3f (ANC2_be[4, 6]) `nancstar2_46' "  \\" _newline
file write `hh' "                    & (" %04.3f (ANC4_se[4, 1]) ") & (" %04.3f (ANC4_se[4, 2]) ") & (" %04.3f (ANC4_se[4, 3]) ") & (" %04.3f (ANC2_se[4, 4]) ") & (" %04.3f (ANC2_se[4, 5]) ") & (" %04.3f (ANC2_se[4, 6]) ") \\" _newline
file write `hh' "                    &                                 &                                 &                                 &                                 &                                 &                         \\\midrule" _newline
file write `hh' "Num of Obs.         &  " (ANC4_obs[1, 1]) " &  " (ANC4_obs[1, 2]) " &  " (ANC4_obs[1, 3]) " &  " (ANC2_obs[1, 4]) " &  " (ANC2_obs[1, 5]) " &  " (ANC2_obs[1, 6]) " \\" _newline
file write `hh' "R-squared           &  " %04.3f (ANC4_r2[1, 1]) "  &  " %04.3f (ANC4_r2[1, 2]) "  &  " %04.3f (ANC4_r2[1, 3]) "  &  " %04.3f (ANC2_r2[1, 4]) "  &  " %04.3f (ANC2_r2[1, 5]) "  &  " %04.3f (ANC2_r2[1, 6]) "  \\" _newline
file write `hh' "                    &                  &          &           &               &         &          \\" _newline
file write `hh' "p-value (individual hypothesis testing) &  " %04.3f (ANC4_pv[1, 1]) "  &  " %04.3f (ANC4_pv[1, 2]) "  &  " %04.3f (ANC4_pv[1, 3]) "  &  " %04.3f (ANC2_pv[1, 4]) "  &  " %04.3f (ANC2_pv[1, 5]) "  &  " %04.3f (ANC2_pv[1, 6]) "  \\" _newline
file write `hh' "p-value (individual hypothesis testing, wild bootstrap) &  " %04.3f (ANC4_wpv[1, 1]) "  &  " %04.3f (ANC4_wpv[1, 2]) "  &  " %04.3f (ANC4_wpv[1, 3]) "  &  " %04.3f (ANC2_wpv[1, 4]) "  &  " %04.3f (ANC2_wpv[1, 5]) "  &  " %04.3f (ANC2_wpv[1, 6]) "  \\" _newline
file write `hh' "                    &                  &          &           &               &         &          \\\bottomrule" _newline






file write `hh' "\end{tabular}" _newline
file write `hh' "\end{threeparttable}" _newline
file write `hh' "}" _newline
file write `hh' "\label{tab:addlabel}%" _newline
file write `hh' "\end{sidewaystable}" _newline

file write `hh' "" _newline
file write `hh' "" _newline
file write `hh' "" _newline
file write `hh' "" _newline

file close `hh'





























